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
838ae0b5
Commit
838ae0b5
authored
Mar 23, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #185 from CocoaPods/improved-search
Improved search
parents
18bc2ab8
5bf9aa05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
11 deletions
+38
-11
search.rb
lib/cocoapods/command/search.rb
+37
-10
git.rb
lib/cocoapods/downloader/git.rb
+1
-1
No files found.
lib/cocoapods/command/search.rb
View file @
838ae0b5
...
@@ -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]
...
@@ -12,11 +12,13 @@ module Pod
...
@@ -12,11 +12,13 @@ module Pod
end
end
def
self
.
options
def
self
.
options
" --stats Show additional stats (like GitHub watchers and forks)
\n
"
+
" --full Search by name, summary, and description
\n
"
+
" --full Search by name, summary, and description
\n
"
+
super
super
end
end
def
initialize
(
argv
)
def
initialize
(
argv
)
@stats
=
argv
.
option
(
'--stats'
)
@full_text_search
=
argv
.
option
(
'--full'
)
@full_text_search
=
argv
.
option
(
'--full'
)
unless
@query
=
argv
.
arguments
.
first
unless
@query
=
argv
.
arguments
.
first
super
super
...
@@ -25,18 +27,43 @@ module Pod
...
@@ -25,18 +27,43 @@ module Pod
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
"==>
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)"
puts
"
\e
[32m-->
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)
\e
[0m"
puts
"
#{
set
.
specification
.
summary
.
strip
}
"
puts
" Homepage:
#{
set
.
specification
.
homepage
}
"
puts_wrapped_text
(
set
.
specification
.
summary
)
puts_detail
(
'Homepage'
,
set
.
specification
.
homepage
)
source
=
set
.
specification
.
source
source
=
set
.
specification
.
source
.
values
[
0
]
if
source
puts_detail
(
'Source'
,
source
)
url
=
source
[
:git
]
||
source
[
:hg
]
||
source
[
:svn
]
||
source
[
:local
]
puts_github_info
(
source
)
if
@stats
puts
" Source:
#{
url
}
"
if
url
end
puts
puts
end
end
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
end
end
end
end
end
end
end
lib/cocoapods/downloader/git.rb
View file @
838ae0b5
...
@@ -64,7 +64,7 @@ module Pod
...
@@ -64,7 +64,7 @@ module Pod
end
end
def
tarball_url_for
(
id
)
def
tarball_url_for
(
id
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/](
\w+)\/(\w+)
.git/
).
to_a
)
original_url
,
username
,
reponame
=
*
(
url
.
match
(
/[:\/](
[\w\-]+)\/([\w\-]+)\
.git/
).
to_a
)
"https://github.com/
#{
username
}
/
#{
reponame
}
/tarball/
#{
id
}
"
"https://github.com/
#{
username
}
/
#{
reponame
}
/tarball/
#{
id
}
"
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