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
9bb3e73e
Commit
9bb3e73e
authored
Mar 23, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert .git behaviour and refactoring
parent
099b7966
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
search.rb
lib/cocoapods/command/search.rb
+35
-20
No files found.
lib/cocoapods/command/search.rb
View file @
9bb3e73e
...
@@ -2,7 +2,7 @@ module Pod
...
@@ -2,7 +2,7 @@ module Pod
class
Command
class
Command
class
Search
<
Command
class
Search
<
Command
def
self
.
banner
def
self
.
banner
%{Search pods:
%{Search pods:
$ pod search [QUERY]
$ pod search [QUERY]
...
@@ -13,7 +13,7 @@ module Pod
...
@@ -13,7 +13,7 @@ module Pod
def
self
.
options
def
self
.
options
" --extended Show details that require network access (like GitHub stats)
\n
"
+
" --extended Show details that require network access (like GitHub stats)
\n
"
+
" --full Search by name, summary, and description
\n
"
+
" --full Search by name, summary, and description
\n
"
super
super
end
end
...
@@ -25,31 +25,46 @@ module Pod
...
@@ -25,31 +25,46 @@ module Pod
end
end
end
end
def
wrap_text
(
txt
,
col
=
80
)
txt
.
gsub
(
/(.{1,
#{
col
}
})( +|$\n?)|(.{1,
#{
col
}
})/
,
"
\\
1
\\
3
\n
"
)
end
def
run
def
run
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
).
each
do
|
set
|
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
).
each
do
|
set
|
puts
"
\e
[32m-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)
\e
[0m"
puts
"
\e
[32m-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)
\e
[0m"
puts
"
#{
wrap_text
(
set
.
specification
.
summary
).
strip
}
"
puts
" - Homepage:
#{
set
.
specification
.
homepage
}
"
puts_wrapped_text
(
set
.
specification
.
summary
)
puts_detail
(
'Homepage'
,
set
.
specification
.
homepage
)
if
@extended
&&
(
source
=
set
.
specification
.
source
)
print_extended_info
(
set
.
specification
.
source
)
if
@extended
url
=
source
[
:git
]
||
source
[
:hg
]
||
source
[
:svn
]
||
source
[
:local
]
puts
" - Source:
#{
url
}
"
if
url
puts
if
url
=~
/github.com/
end
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/](\w+)\/(\w+)(.git)?/
).
to_a
)
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
number_of_spaces
=
((
8
-
title
.
length
)
>
0
)
?
(
8
-
title
.
length
)
:
0
spaces
=
' '
*
number_of_spaces
puts
" -
#{
title
}
:
#{
spaces
+
string
}
"
end
def
print_extended_info
(
source
)
source_url
=
source
[
:git
]
||
source
[
:hg
]
||
source
[
:svn
]
||
source
[
:local
]
puts_detail
(
'Source'
,
source_url
)
print_github_info
(
source_url
)
if
source_url
=~
/github.com/
end
def
print_github_info
(
url
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/]([\w\-]+)\/([\w\-]+)\.git/
).
to_a
)
if
original_url
if
original_url
repo_info
=
`curl -s -m 2 http://github.com/api/v2/json/repos/show/
#{
username
}
/
#{
reponame
}
`
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
]
watchers
=
repo_info
.
match
(
/\"watchers\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
forks
=
repo_info
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
forks
=
repo_info
.
match
(
/\"forks\"\W*:\W*([0-9]+)/
).
to_a
[
1
]
puts
" - Watchers: "
+
watchers
if
watchers
puts_detail
(
'Watchers'
,
watchers
)
puts
" - Forks: "
+
forks
if
forks
puts_detail
(
'Forks'
,
forks
)
end
end
end
puts
end
end
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