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
d68d308b
Commit
d68d308b
authored
Mar 24, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[list-new] Extratect pod display logic from pod search.
parent
8bc4144c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
39 deletions
+57
-39
command.rb
lib/cocoapods/command.rb
+1
-0
print_pod.rb
lib/cocoapods/command/print_pod.rb
+51
-0
search.rb
lib/cocoapods/command/search.rb
+5
-39
No files found.
lib/cocoapods/command.rb
View file @
d68d308b
module
Pod
class
Command
autoload
:ErrorReport
,
'cocoapods/command/error_report'
autoload
:DisplayPods
,
'cocoapods/command/print_pod'
autoload
:Install
,
'cocoapods/command/install'
autoload
:List
,
'cocoapods/command/list'
autoload
:Repo
,
'cocoapods/command/repo'
...
...
lib/cocoapods/command/print_pod.rb
0 → 100644
View file @
d68d308b
module
Pod
class
Command
module
DisplayPods
def
display_pod_list
(
array
,
stats
=
false
)
array
.
each
do
|
set
|
puts_pod
(
set
,
stats
)
end
end
def
puts_pod
(
set
,
stats
=
false
)
puts
"
\e
[32m-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)
\e
[0m"
puts_wrapped_text
(
set
.
specification
.
summary
)
spec
=
set
.
specification
.
part_of_other_pod?
?
set
.
specification
.
part_of_specification
:
set
.
specification
source
=
spec
.
source
.
reject
{
|
k
,
_
|
k
==
:commit
||
k
==
:tag
}.
values
.
first
puts_detail
(
'Homepage'
,
spec
.
homepage
)
puts_detail
(
'Source'
,
source
)
puts_github_info
(
source
)
if
stats
puts
end
# adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
def
puts_wrapped_text
(
txt
,
col
=
80
,
indentation
=
4
)
indent
=
' '
*
indentation
puts
txt
.
strip
.
gsub
(
/(.{1,
#{
col
}
})( +|$)\n?|(.{
#{
col
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
def
puts_detail
(
title
,
string
)
return
if
!
string
# 8 is the length of homepage which might be displayed alone
number_of_spaces
=
((
8
-
title
.
length
)
>
0
)
?
(
8
-
title
.
length
)
:
0
spaces
=
' '
*
number_of_spaces
puts
" -
#{
title
}
:
#{
spaces
+
string
}
"
end
def
puts_github_info
(
url
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/]([\w\-]+)\/([\w\-]+)\.git/
).
to_a
)
if
original_url
repo_info
=
`curl -s -m 2 http://github.com/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
`
watchers
=
repo_info
.
match
(
/\"watchers\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
forks
=
repo_info
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
puts_detail
(
'Watchers'
,
watchers
)
puts_detail
(
'Forks'
,
forks
)
end
end
end
end
end
lib/cocoapods/command/search.rb
View file @
d68d308b
module
Pod
class
Command
class
Search
<
Command
include
DisplayPods
def
self
.
banner
%{Search pods:
...
...
@@ -26,45 +29,8 @@ module Pod
end
def
run
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
).
each
do
|
set
|
puts
"
\e
[32m-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)
\e
[0m"
puts_wrapped_text
(
set
.
specification
.
summary
)
spec
=
set
.
specification
.
part_of_other_pod?
?
set
.
specification
.
part_of_specification
:
set
.
specification
source
=
spec
.
source
.
reject
{
|
k
,
_
|
k
==
:commit
||
k
==
:tag
}.
values
.
first
puts_detail
(
'Homepage'
,
spec
.
homepage
)
puts_detail
(
'Source'
,
source
)
puts_github_info
(
source
)
if
@stats
puts
end
end
# adapted from http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
def
puts_wrapped_text
(
txt
,
col
=
80
,
indentation
=
4
)
indent
=
' '
*
indentation
puts
txt
.
strip
.
gsub
(
/(.{1,
#{
col
}
})( +|$)\n?|(.{
#{
col
}
})/
,
indent
+
"
\\
1
\\
3
\n
"
)
end
def
puts_detail
(
title
,
string
)
return
if
!
string
# 8 is the length of homepage which might be displayed alone
number_of_spaces
=
((
8
-
title
.
length
)
>
0
)
?
(
8
-
title
.
length
)
:
0
spaces
=
' '
*
number_of_spaces
puts
" -
#{
title
}
:
#{
spaces
+
string
}
"
end
def
puts_github_info
(
url
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/]([\w\-]+)\/([\w\-]+)\.git/
).
to_a
)
if
original_url
repo_info
=
`curl -s -m 2 http://github.com/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
`
watchers
=
repo_info
.
match
(
/\"watchers\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
forks
=
repo_info
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
puts_detail
(
'Watchers'
,
watchers
)
puts_detail
(
'Forks'
,
forks
)
end
sets
=
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
)
display_pod_list
(
sets
,
@stats
)
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