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
b497b8fa
Commit
b497b8fa
authored
Sep 17, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search through summary and description with `--full'.
parent
9a6268ff
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
13 deletions
+68
-13
search.rb
lib/cocoapods/command/search.rb
+17
-1
source.rb
lib/cocoapods/source.rb
+22
-11
command_spec.rb
spec/functional/command_spec.rb
+28
-1
set_spec.rb
spec/unit/specification/set_spec.rb
+1
-0
No files found.
lib/cocoapods/command/search.rb
View file @
b497b8fa
module
Pod
class
Command
class
Search
<
Command
def
self
.
banner
%{Search pods:
$ pod search [QUERY]
Searches for pods, ignoring case, whose name matches `QUERY'. If the
`--full' option is specified, this will also search in the summary and
description of the pods.}
end
def
self
.
options
" --full Search by name, summary, and description
\n
"
+
super
end
def
initialize
(
argv
)
@full_text_search
=
argv
.
option
(
'--full'
)
unless
@query
=
argv
.
arguments
.
first
super
end
end
def
run
Source
.
search_by_name
(
@query
.
strip
).
each
do
|
set
|
Source
.
search_by_name
(
@query
.
strip
,
@full_text_search
).
each
do
|
set
|
puts
"
#{
set
.
name
}
(
#{
set
.
versions
.
reverse
.
join
(
", "
)
}
)"
end
end
...
...
lib/cocoapods/source.rb
View file @
b497b8fa
...
...
@@ -12,12 +12,12 @@ module Pod
end
def
self
.
search
(
dependency
)
all
.
map
{
|
s
ource
|
source
.
search
(
dependency
)
}.
compact
.
first
||
all
.
map
{
|
s
|
s
.
search
(
dependency
)
}.
compact
.
first
||
raise
(
Informative
,
"Unable to find a pod named `
#{
dependency
.
name
}
'"
)
end
def
self
.
search_by_name
(
query
)
result
=
all
.
map
{
|
s
ource
|
source
.
search_by_name
(
query
)
}.
flatten
def
self
.
search_by_name
(
query
,
full_text_search
)
result
=
all
.
map
{
|
s
|
s
.
search_by_name
(
query
,
full_text_search
)
}.
flatten
if
result
.
empty?
raise
(
Informative
,
"Unable to find a pod who's name matches `
#{
query
}
'"
)
end
...
...
@@ -30,17 +30,28 @@ module Pod
@repo
=
repo
end
def
pod_sets
@repo
.
children
.
map
do
|
child
|
if
child
.
directory?
&&
child
.
basename
.
to_s
!=
'.git'
Specification
::
Set
.
by_pod_dir
(
child
)
end
end
.
compact
end
def
search
(
dependency
)
if
dir
=
@repo
.
children
.
find
{
|
c
|
c
.
basename
.
to_s
==
dependency
.
name
}
Specification
::
Set
.
by_pod_dir
(
dir
)
end
pod_sets
.
find
{
|
set
|
set
.
name
==
dependency
.
name
}
end
def
search_by_name
(
query
)
dirs
=
@repo
.
children
.
select
do
|
child
|
child
.
basename
.
to_s
.
downcase
.
include?
(
query
.
downcase
)
end
dirs
.
map
{
|
dir
|
Specification
::
Set
.
by_pod_dir
(
dir
)
}
def
search_by_name
(
query
,
full_text_search
)
pod_sets
.
map
do
|
set
|
text
=
if
full_text_search
s
=
set
.
specification
"
#{
s
.
read
(
:name
)
}
#{
s
.
read
(
:summary
)
}
#{
s
.
read
(
:description
)
}
"
else
set
.
name
end
set
if
text
.
downcase
.
include?
(
query
.
downcase
)
end
.
compact
end
end
end
spec/functional/command_spec.rb
View file @
b497b8fa
...
...
@@ -64,7 +64,34 @@ describe "Pod::Command" do
]
]
].
each
do
|
query
,
result
|
command
=
Pod
::
Command
.
parse
(
'search'
,
query
)
command
=
Pod
::
Command
.
parse
(
'search'
,
'--silent'
,
query
)
def
command
.
puts
(
msg
)
(
@printed
||=
[])
<<
msg
end
command
.
run
printed
=
command
.
instance_variable_get
(
:@printed
)
printed
.
should
==
result
.
sort
end
end
it
"searches for a pod who's name, summary, or description matches the given query ignoring case"
do
[
[
'systemCONfiguration'
,
[
"Reachability (2.0.4)"
]
],
[
'is'
,
[
"ASIHTTPRequest (1.8, 1.8.1)"
,
"Reachability (2.0.4)"
,
"SSZipArchive (1.0)"
]
]
].
each
do
|
query
,
result
|
command
=
Pod
::
Command
.
parse
(
'search'
,
'--silent'
,
'--full'
,
query
)
def
command
.
puts
(
msg
)
(
@printed
||=
[])
<<
msg
end
...
...
spec/unit/specification/set_spec.rb
View file @
b497b8fa
...
...
@@ -8,6 +8,7 @@ end
describe
"Pod::Specification::Set"
do
it
"returns nil in case a set hasn't been resolved yet"
do
Pod
::
Spec
::
Set
.
reset!
Pod
::
Spec
::
Set
.
by_specification_name
(
'ASIHTTPRequest'
).
should
==
nil
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