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
f9fa8db6
Commit
f9fa8db6
authored
Dec 14, 2013
by
Florian R. Hanke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement --web search command option (see #1682). Add specs for the --web search option.
parent
5f506b49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
4 deletions
+69
-4
CHANGELOG.md
CHANGELOG.md
+11
-0
search.rb
lib/cocoapods/command/search.rb
+28
-3
search_spec.rb
spec/functional/command/search_spec.rb
+30
-1
No files found.
CHANGELOG.md
View file @
f9fa8db6
...
...
@@ -39,6 +39,17 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
test doesn't affect the normal workflow.
[
Fabio Pelosin
](
https://github.com/irrationalfab
)
*
The
`pod search <query>`
command now supports searching on cocoapods.org
when searching using the option
`--web`
. Options
`--ios`
and
`--osx`
are
fully supported.
[
Florian Hanke
](
https://github.com/floere
)
[
#1643
][
https://github.com/CocoaPods/CocoaPods/pull/1682
]
*
The
`pod search <query>`
command now supports multiword queries when using
the
`--web`
option.
[
Florian Hanke
](
https://github.com/floere
)
[
#1643
][
https://github.com/CocoaPods/CocoaPods/pull/1682
]
###### Refactor
*
The command
`podfile_info`
is now a plugin offered by CocoaPods.
...
...
lib/cocoapods/command/search.rb
View file @
f9fa8db6
...
...
@@ -16,7 +16,8 @@ module Pod
[
"--full"
,
"Search by name, summary, and description"
],
[
"--stats"
,
"Show additional stats (like GitHub watchers and forks)"
],
[
"--ios"
,
"Restricts the search to Pods supported on iOS"
],
[
"--osx"
,
"Restricts the search to Pods supported on OS X"
]
[
"--osx"
,
"Restricts the search to Pods supported on OS X"
],
[
"--web"
,
"Searches on cocoapods.org"
]
].
concat
(
super
.
reject
{
|
option
,
_
|
option
==
'--silent'
})
end
...
...
@@ -25,7 +26,8 @@ module Pod
@stats
=
argv
.
flag?
(
'stats'
)
@supported_on_ios
=
argv
.
flag?
(
'ios'
)
@supported_on_osx
=
argv
.
flag?
(
'osx'
)
@query
=
argv
.
shift_argument
@web
=
argv
.
flag?
(
'web'
)
@query
=
argv
.
arguments!
unless
argv
.
arguments
.
empty?
config
.
silent
=
false
super
end
...
...
@@ -36,7 +38,29 @@ module Pod
end
def
run
sets
=
SourcesManager
.
search_by_name
(
@query
.
strip
,
@full_text_search
)
if
@web
web_search
else
local_search
end
end
extend
Executable
executable
:open
def
web_search
query_parameter
=
[
(
'on%3Aosx'
if
@supported_on_osx
),
(
'on%3Aios'
if
@supported_on_ios
),
@query
].
compact
.
flatten
.
join
(
'%20'
)
url
=
"http://cocoapods.org/?q=
#{
query_parameter
}
"
UI
.
puts
(
"Opening
#{
url
}
"
)
open
!
(
url
)
end
def
local_search
sets
=
SourcesManager
.
search_by_name
(
@query
.
join
(
' '
).
strip
,
@full_text_search
)
if
@supported_on_ios
sets
.
reject!
{
|
set
|
!
set
.
specification
.
available_platforms
.
map
(
&
:name
).
include?
(
:ios
)
}
end
...
...
@@ -57,6 +81,7 @@ module Pod
end
end
end
end
end
end
spec/functional/command/search_spec.rb
View file @
f9fa8db6
...
...
@@ -18,7 +18,6 @@ module Pod
it
"complains for wrong parameters"
do
lambda
{
run_command
(
'search'
)
}.
should
.
raise
CLAide
::
Help
lambda
{
run_command
(
'search'
,
'too'
,
'many'
)
}.
should
.
raise
CLAide
::
Help
lambda
{
run_command
(
'search'
,
'too'
,
'--wrong'
)
}.
should
.
raise
CLAide
::
Help
lambda
{
run_command
(
'search'
,
'--wrong'
)
}.
should
.
raise
CLAide
::
Help
end
...
...
@@ -50,5 +49,35 @@ module Pod
output
=
run_command
(
'search'
,
'BananaLib'
,
'--silent'
)
output
.
should
.
include?
'BananaLib'
end
describe
"option --web"
do
extend
SpecHelper
::
TemporaryRepos
it
"searches the web via the open! command"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=bananalib'
)
run_command
(
'search'
,
'--web'
,
'bananalib'
)
end
it
"includes option --osx correctly"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=on%3Aosx%20bananalib'
)
run_command
(
'search'
,
'--web'
,
'--osx'
,
'bananalib'
)
end
it
"includes option --ios correctly"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=on%3Aios%20bananalib'
)
run_command
(
'search'
,
'--web'
,
'--ios'
,
'bananalib'
)
end
it
"does not matter in which order the ios/osx options are set"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=on%3Aosx%20on%3Aios%20bananalib'
)
run_command
(
'search'
,
'--web'
,
'--ios'
,
'--osx'
,
'bananalib'
)
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=on%3Aosx%20on%3Aios%20bananalib'
)
run_command
(
'search'
,
'--web'
,
'--osx'
,
'--ios'
,
'bananalib'
)
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