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
c8bc4a7d
Commit
c8bc4a7d
authored
Apr 10, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[pod-list] new class Pod::Specification::Statistics
parent
84f9bd51
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
67 deletions
+63
-67
command.rb
lib/cocoapods/command.rb
+2
-1
list.rb
lib/cocoapods/command/list.rb
+3
-3
presenter.rb
lib/cocoapods/command/presenter.rb
+6
-6
specification.rb
lib/cocoapods/specification.rb
+2
-23
set.rb
lib/cocoapods/specification/set.rb
+0
-34
statistics.rb
lib/cocoapods/specification/statistics.rb
+50
-0
No files found.
lib/cocoapods/command.rb
View file @
c8bc4a7d
...
@@ -5,11 +5,12 @@ module Pod
...
@@ -5,11 +5,12 @@ module Pod
autoload
:ErrorReport
,
'cocoapods/command/error_report'
autoload
:ErrorReport
,
'cocoapods/command/error_report'
autoload
:Install
,
'cocoapods/command/install'
autoload
:Install
,
'cocoapods/command/install'
autoload
:List
,
'cocoapods/command/list'
autoload
:List
,
'cocoapods/command/list'
autoload
:Presenter
,
'cocoapods/command/presenter'
autoload
:Repo
,
'cocoapods/command/repo'
autoload
:Repo
,
'cocoapods/command/repo'
autoload
:Search
,
'cocoapods/command/search'
autoload
:Search
,
'cocoapods/command/search'
autoload
:Setup
,
'cocoapods/command/setup'
autoload
:Setup
,
'cocoapods/command/setup'
autoload
:Spec
,
'cocoapods/command/spec'
autoload
:Spec
,
'cocoapods/command/spec'
autoload
:
Presenter
,
'cocoapods/command/presenter
'
autoload
:
Statistics
,
'cocoapods/specification/statistics
'
class
Help
<
Informative
class
Help
<
Informative
def
initialize
(
command_class
,
argv
)
def
initialize
(
command_class
,
argv
)
...
...
lib/cocoapods/command/list.rb
View file @
c8bc4a7d
...
@@ -37,8 +37,8 @@ module Pod
...
@@ -37,8 +37,8 @@ module Pod
days
=
[
1
,
2
,
3
,
5
,
8
]
days
=
[
1
,
2
,
3
,
5
,
8
]
dates
,
groups
=
{},
{}
dates
,
groups
=
{},
{}
days
.
each
{
|
d
|
dates
[
d
]
=
Time
.
now
-
60
*
60
*
24
*
d
}
days
.
each
{
|
d
|
dates
[
d
]
=
Time
.
now
-
60
*
60
*
24
*
d
}
Source
.
all_sets
.
sort_by
{
|
set
|
set
.
creation_date
}.
each
do
|
set
|
Source
.
all_sets
.
each
do
|
set
|
set_date
=
set
.
creation_date
set_date
=
Pod
::
Specification
::
Statistics
.
new
(
set
)
.
creation_date
days
.
each
do
|
d
|
days
.
each
do
|
d
|
if
set_date
>
dates
[
d
]
if
set_date
>
dates
[
d
]
groups
[
d
]
=
[]
unless
groups
[
d
]
groups
[
d
]
=
[]
unless
groups
[
d
]
...
@@ -52,7 +52,7 @@ module Pod
...
@@ -52,7 +52,7 @@ module Pod
sets
=
groups
[
d
]
sets
=
groups
[
d
]
next
unless
sets
next
unless
sets
puts
"Pods added in the last
#{
d
==
1
?
'1 day'
:
"
#{
d
}
days"
}
"
.
yellow
puts
"Pods added in the last
#{
d
==
1
?
'1 day'
:
"
#{
d
}
days"
}
"
.
yellow
@presenter
.
present_sets
(
sets
)
@presenter
.
present_sets
(
sets
.
sort_by
{
|
set
|
Pod
::
Specification
::
Statistics
.
new
(
set
).
creation_date
}
)
end
end
end
end
...
...
lib/cocoapods/command/presenter.rb
View file @
c8bc4a7d
...
@@ -15,13 +15,13 @@ module Pod
...
@@ -15,13 +15,13 @@ module Pod
end
end
def
present_set
(
set
)
def
present_set
(
set
)
stats
=
Pod
::
Specification
::
Statistics
.
new
(
set
)
puts
"-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)"
.
green
puts
"-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)"
.
green
puts
wrap_string
(
set
.
summary
)
puts
wrap_string
(
stats
.
summary
)
spec
=
set
.
specification
.
part_of_other_pod?
?
set
.
specification
.
part_of_specification
:
set
.
specification
puts_detail
(
'Homepage'
,
stats
.
homepage
)
puts_detail
(
'Homepage'
,
spec
.
homepage
)
puts_detail
(
'Source'
,
stats
.
source_url
)
puts_detail
(
'Source'
,
spec
.
source_url
)
puts_detail
(
'Watchers'
,
stats
.
github_watchers
)
if
@stats
puts_detail
(
'Watchers'
,
spec
.
github_watchers
)
if
@stats
puts_detail
(
'Forks'
,
stats
.
github_forks
)
if
@stats
puts_detail
(
'Forks'
,
spec
.
github_forks
)
if
@stats
puts
puts
end
end
...
...
lib/cocoapods/specification.rb
View file @
c8bc4a7d
...
@@ -9,7 +9,8 @@ module Pod
...
@@ -9,7 +9,8 @@ module Pod
end
end
class
Specification
class
Specification
autoload
:Set
,
'cocoapods/specification/set'
autoload
:Set
,
'cocoapods/specification/set'
autoload
:Statistics
,
'cocoapods/specification/statistics'
# The file is expected to define and return a Pods::Specification.
# The file is expected to define and return a Pods::Specification.
def
self
.
from_file
(
path
)
def
self
.
from_file
(
path
)
...
@@ -131,28 +132,6 @@ module Pod
...
@@ -131,28 +132,6 @@ module Pod
@header_dir
||
pod_destroot_name
@header_dir
||
pod_destroot_name
end
end
def
source_url
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
attr_writer
:compiler_flags
def
compiler_flags
def
compiler_flags
flags
=
"
#{
@compiler_flags
}
"
flags
=
"
#{
@compiler_flags
}
"
...
...
lib/cocoapods/specification/set.rb
View file @
c8bc4a7d
...
@@ -67,40 +67,6 @@ module Pod
...
@@ -67,40 +67,6 @@ module Pod
end
.
compact
.
sort
.
reverse
end
.
compact
.
sort
.
reverse
end
end
def
creation_date
Dir
.
chdir
(
@pod_dir
.
dirname
)
do
@creation_date
||=
Time
.
at
(
`git log --format=%ct ./
#{
name
}
| tail -1`
.
to_i
)
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
class
External
<
Set
def
initialize
(
specification
)
def
initialize
(
specification
)
@specification
=
specification
@specification
=
specification
...
...
lib/cocoapods/specification/statistics.rb
0 → 100644
View file @
c8bc4a7d
require
'net/http'
module
Pod
class
Specification
class
Statistics
def
initialize
(
set
)
@set
=
set
@spec
=
set
.
specification
.
part_of_other_pod?
?
set
.
specification
.
part_of_specification
:
set
.
specification
end
def
creation_date
Dir
.
chdir
(
@set
.
pod_dir
.
dirname
)
do
@creation_date
||=
Time
.
at
(
`git log --format=%ct ./
#{
@set
.
name
}
| tail -1`
.
to_i
)
end
end
def
homepage
@spec
.
homepage
end
def
description
@spec
.
description
end
def
summary
@spec
.
summary
end
def
source_url
@spec
.
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
github_response
.
match
(
/\"watchers\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
if
github_response
end
def
github_forks
github_response
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
if
github_response
end
end
end
end
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