Skip to content

Commit

Permalink
Move all platforms logic to Core.
Browse files Browse the repository at this point in the history
  • Loading branch information
manuyavuz committed Oct 30, 2015
1 parent c0445af commit 1ea0580
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

##### Enhancements

* Add support for tvOS and any possible future platforms
* Add support for tvOS and any possible future platforms.
[Muhammed Yavuz Nuzumlalı](https://github.com/manuyavuz)
[#11](https://github.com/CocoaPods/cocoapods-search/issues/11)

* Perform regexp escape on individual query words before joining them
* Perform regexp escape on individual query words before joining them.
[Muhammed Yavuz Nuzumlalı](https://github.com/manuyavuz)
[#8](https://github.com/CocoaPods/cocoapods-search/issues/8)

Expand Down
18 changes: 4 additions & 14 deletions lib/cocoapods-search/command/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,15 @@ class Search < Command
CLAide::Argument.new('QUERY', true),
]

def self.all_platforms
Specification::PLATFORMS.map do |platform|
platform.to_s
end
end

def all_platforms
self.class.all_platforms
end

def self.options
options = [
['--regex', 'Interpret the `QUERY` as a regular expression'],
['--full', 'Search by name, summary, description, and authors'],
['--stats', 'Show additional stats (like GitHub watchers and forks)'],
['--web', 'Searches on cocoapods.org'],
]
options += all_platforms.map do |platform|
["--#{platform}", "Restricts the search to Pods supported on #{platform}"]
options += Platform.all.map do |platform|
["--#{platform.name.to_s}", "Restricts the search to Pods supported on #{Platform.string_name(platform.to_sym)}"]
end
options.concat(super.reject { |option, _| option == '--silent' })
end
Expand All @@ -41,8 +31,8 @@ def initialize(argv)
@full_text_search = argv.flag?('full')
@stats = argv.flag?('stats')
@web = argv.flag?('web')
@platform_filters = all_platforms.map do |platform|
argv.flag?(platform) ? platform.to_sym : nil
@platform_filters = Platform.all.map do |platform|
argv.flag?(platform.name.to_s) ? platform.to_sym : nil
end.compact
@query = argv.arguments! unless argv.arguments.empty?
config.silent = false
Expand Down
6 changes: 3 additions & 3 deletions spec/command/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ module Pod
end

it 'includes any new platform option correctly' do
Command::Search.any_instance.stubs(:all_platforms).returns(%w(ios osx watchos tvos whateveros))
Platform.stubs(:all).returns([Platform.ios, Platform.tvos, Platform.new('whateveros')])
Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Awhateveros%20bananalib')
run_command('search', '--web', '--whateveros', 'bananalib')
end

it 'does not matter in which order the ios/osx options are set' do
Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Aosx%20on%3Aios%20bananalib')
Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Aios%20on%3Aosx%20bananalib')
run_command('search', '--web', '--ios', '--osx', 'bananalib')

Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Aosx%20on%3Aios%20bananalib')
Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Aios%20on%3Aosx%20bananalib')
run_command('search', '--web', '--osx', '--ios', 'bananalib')
end
end
Expand Down

0 comments on commit 1ea0580

Please sign in to comment.