Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
85827809
Commit
85827809
authored
Apr 10, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[pod-list] refactoring
parent
e46364e6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
29 deletions
+56
-29
list.rb
lib/cocoapods/command/list.rb
+4
-8
set_present.rb
lib/cocoapods/command/set_present.rb
+6
-21
specification.rb
lib/cocoapods/specification.rb
+18
-0
set.rb
lib/cocoapods/specification/set.rb
+28
-0
No files found.
lib/cocoapods/command/list.rb
View file @
85827809
...
...
@@ -29,12 +29,8 @@ module Pod
super
unless
argv
.
empty?
end
def
dir
config
.
repos_dir
+
'master'
end
def
last_check_file
config
.
repos_dir
+
'list_new
.txt
'
config
.
repos_dir
+
'list_new'
end
def
update_last_check_time
(
time
)
...
...
@@ -48,7 +44,7 @@ module Pod
Time
.
now
-
60
*
60
*
24
*
15
end
def
new_s
pec
s_since
(
time
)
def
new_s
et
s_since
(
time
)
all
=
Source
.
all_sets
all
.
reject!
{
|
set
|
(
set
.
creation_date
-
time
).
to_i
<=
0
}
all
.
sort_by
{
|
set
|
set
.
creation_date
}
...
...
@@ -57,7 +53,7 @@ module Pod
def
list_new
time
=
last_check_time
time_string
=
time
.
strftime
(
"%A %m %B %Y (%H:%M)"
)
sets
=
new_s
pec
s_since
(
time
)
sets
=
new_s
et
s_since
(
time
)
if
sets
.
empty?
puts
"
\n
No new pods were added since
#{
time
.
localtime
}
"
unless
list
else
...
...
@@ -77,7 +73,7 @@ module Pod
def
run
if
@new
puts
"
\n
Updating Spec Repositories
\n
"
.
yellow
if
config
.
verbose?
#
Repo.new(ARGV.new(["update"])).run
Repo
.
new
(
ARGV
.
new
([
"update"
])).
run
list_new
else
list_all
...
...
lib/cocoapods/command/set_present.rb
View file @
85827809
...
...
@@ -8,7 +8,7 @@ module Pod
" --stats Show additional stats (like GitHub watchers and forks)
\n
"
end
def
list
def
list
@list
end
...
...
@@ -18,9 +18,7 @@ module Pod
end
def
present_sets
(
array
)
array
.
each
do
|
set
|
present_set
(
set
)
end
array
.
each
{
|
set
|
present_set
(
set
)}
end
def
present_set
(
set
)
...
...
@@ -28,15 +26,14 @@ module Pod
puts
set
.
name
else
puts
"-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)"
.
green
puts_wrapped_text
(
set
.
s
pecification
.
s
ummary
)
puts_wrapped_text
(
set
.
summary
)
spec
=
set
.
specification
.
part_of_other_pod?
?
set
.
specification
.
part_of_specification
:
set
.
specification
puts_detail
(
'Homepage'
,
spec
.
homepage
)
puts_detail
(
'Source'
,
spec
.
source_url
)
if
@stats
stats
=
stats
(
spec
.
source_url
)
puts_detail
(
'Watchers'
,
stats
[
:watchers
])
puts_detail
(
'Forks'
,
stats
[
:forks
])
puts_detail
(
'Watchers'
,
spec
.
github_watchers
)
puts_detail
(
'Forks'
,
spec
.
github_forks
)
end
puts
end
...
...
@@ -55,18 +52,6 @@ module Pod
spaces
=
' '
*
number_of_spaces
puts
" -
#{
title
}
:
#{
spaces
+
string
}
"
end
def
stats
(
url
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/]([\w\-]+)\/([\w\-]+)\.git/
).
to_a
)
result
=
{}
if
original_url
gh_response
=
Net
::
HTTP
.
get
(
'github.com'
,
"/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
"
)
result
[
:watchers
]
=
gh_response
.
match
(
/\"watchers\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
result
[
:forks
]
=
gh_response
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
end
result
end
end
end
end
lib/cocoapods/specification.rb
View file @
85827809
...
...
@@ -135,6 +135,24 @@ module Pod
source
.
reject
{
|
k
,
_
|
k
==
:commit
||
k
==
:tag
}.
values
.
first
end
def
github_response
return
@github_response
if
@github_response
github_url
,
username
,
reponame
=
*
(
source_url
.
match
(
/[:\/]([\w\-]+)\/([\w\-]+)\.git/
).
to_a
)
if
github_url
@github_response
=
Net
::
HTTP
.
get
(
'github.com'
,
"/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
"
)
end
end
def
github_watchers
return
"123"
github_response
.
match
(
/\"watchers\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
if
github_response
end
def
github_forks
return
"456"
github_response
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
if
github_response
end
attr_writer
:compiler_flags
def
compiler_flags
flags
=
"
#{
@compiler_flags
}
"
...
...
lib/cocoapods/specification/set.rb
View file @
85827809
...
...
@@ -73,6 +73,34 @@ module Pod
end
end
def
super_specification
@super_specification
||=
specification
.
part_of_other_pod?
?
specification
.
part_of_specification
:
specification
end
def
homepage
super_specification
.
homepage
end
def
description
super_specification
.
description
end
def
summary
super_specification
.
summary
end
def
source_url
super_specification
.
source_url
end
def
github_watchers
super_specification
.
github_watchers
end
def
github_forks
super_specification
.
github_forks
end
class
External
<
Set
def
initialize
(
specification
)
@specification
=
specification
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment