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
22518894
Commit
22518894
authored
Mar 27, 2014
by
Florian R. Hanke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1893 from CocoaPods/web_search_regex
Web search regex
parents
9c478fbe
9471d58c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
search.rb
lib/cocoapods/command/search.rb
+8
-4
search_spec.rb
spec/functional/command/search_spec.rb
+11
-1
No files found.
lib/cocoapods/command/search.rb
View file @
22518894
...
@@ -36,10 +36,14 @@ module Pod
...
@@ -36,10 +36,14 @@ module Pod
super
super
help!
"A search query is required."
unless
@query
help!
"A search query is required."
unless
@query
unless
@web
begin
/
#{
@query
.
join
(
' '
).
strip
}
/
/
#{
@query
.
join
(
' '
).
strip
}
/
rescue
RegexpError
rescue
RegexpError
help!
"A valid regular expression is required."
help!
"A valid regular expression is required."
end
end
end
end
def
run
def
run
if
@web
if
@web
...
@@ -54,11 +58,11 @@ module Pod
...
@@ -54,11 +58,11 @@ module Pod
def
web_search
def
web_search
query_parameter
=
[
query_parameter
=
[
(
'on
%3A
osx'
if
@supported_on_osx
),
(
'on
:
osx'
if
@supported_on_osx
),
(
'on
%3A
ios'
if
@supported_on_ios
),
(
'on
:
ios'
if
@supported_on_ios
),
@query
@query
].
compact
.
flatten
.
join
(
'
%20
'
)
].
compact
.
flatten
.
join
(
'
'
)
url
=
"http://cocoapods.org/?q=
#{
query_parameter
}
"
url
=
"http://cocoapods.org/?q=
#{
CGI
.
escape
(
query_parameter
).
gsub
(
"+"
,
"%20"
)
}
"
UI
.
puts
(
"Opening
#{
url
}
"
)
UI
.
puts
(
"Opening
#{
url
}
"
)
open
!
(
url
)
open
!
(
url
)
end
end
...
...
spec/functional/command/search_spec.rb
View file @
22518894
...
@@ -50,7 +50,7 @@ module Pod
...
@@ -50,7 +50,7 @@ module Pod
output
.
should
.
include?
'BananaLib'
output
.
should
.
include?
'BananaLib'
end
end
it
"shows a friendly message when searching with invalid regex"
do
it
"shows a friendly message when
locally
searching with invalid regex"
do
lambda
{
run_command
(
'search'
,
'+'
)
}.
should
.
raise
CLAide
::
Help
lambda
{
run_command
(
'search'
,
'+'
)
}.
should
.
raise
CLAide
::
Help
end
end
...
@@ -58,6 +58,16 @@ module Pod
...
@@ -58,6 +58,16 @@ module Pod
extend
SpecHelper
::
TemporaryRepos
extend
SpecHelper
::
TemporaryRepos
it
"searches with invalid regex"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=NSAttributedString%2BCCLFormat'
)
run_command
(
'search'
,
'--web'
,
'NSAttributedString+CCLFormat'
)
end
it
"should url encode search queries"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=NSAttributedString%2BCCLFormat'
)
run_command
(
'search'
,
'--web'
,
'NSAttributedString+CCLFormat'
)
end
it
"searches the web via the open! command"
do
it
"searches the web via the open! command"
do
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=bananalib'
)
Command
::
Search
.
any_instance
.
expects
(
:open!
).
with
(
'http://cocoapods.org/?q=bananalib'
)
run_command
(
'search'
,
'--web'
,
'bananalib'
)
run_command
(
'search'
,
'--web'
,
'bananalib'
)
...
...
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