From c0445af84b2c92823921cccef6b17dd8c8463474 Mon Sep 17 00:00:00 2001 From: Muhammed Yavuz Nuzumlali Date: Fri, 30 Oct 2015 15:17:07 +0300 Subject: [PATCH 1/3] Add support for tvOS and any possible future platforms. - Include specs for missing watchos cases, tvos, and any future platform. - Update Gemfile.lock to cocoapods 0.39.0 --- CHANGELOG.md | 6 +++ Gemfile.lock | 47 +++++++++++++----------- lib/cocoapods-search/command/search.rb | 51 ++++++++++++++------------ spec/command/search_spec.rb | 22 +++++++++++ 4 files changed, 81 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a898cff..8acdd2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Master +##### Enhancements + +* 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 [Muhammed Yavuz Nuzumlalı](https://github.com/manuyavuz) [#8](https://github.com/CocoaPods/cocoapods-search/issues/8) diff --git a/Gemfile.lock b/Gemfile.lock index 722792c..ae26ad6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,33 +14,33 @@ GEM tzinfo (~> 1.1) bacon (1.2.0) claide (0.9.1) - cocoapods (0.38.2) - activesupport (>= 3.2.15) + cocoapods (0.39.0) + activesupport (>= 4.0.2) claide (~> 0.9.1) - cocoapods-core (= 0.38.2) - cocoapods-downloader (~> 0.9.1) + cocoapods-core (= 0.39.0) + cocoapods-downloader (~> 0.9.3) cocoapods-plugins (~> 0.4.2) - cocoapods-stats (~> 0.5.3) - cocoapods-trunk (~> 0.6.1) - cocoapods-try (~> 0.4.5) + cocoapods-search (~> 0.1.0) + cocoapods-stats (~> 0.6.2) + cocoapods-trunk (~> 0.6.4) + cocoapods-try (~> 0.5.1) colored (~> 1.2) escape (~> 0.0.4) - molinillo (~> 0.3.1) - nap (~> 0.8) - xcodeproj (~> 0.26.3) - cocoapods-core (0.38.2) - activesupport (>= 3.2.15) + molinillo (~> 0.4.0) + nap (~> 1.0) + xcodeproj (~> 0.28.2) + cocoapods-core (0.39.0) + activesupport (>= 4.0.2) fuzzy_match (~> 2.0.4) - nap (~> 0.8.0) - cocoapods-downloader (0.9.1) + nap (~> 1.0) + cocoapods-downloader (0.9.3) cocoapods-plugins (0.4.2) nap - cocoapods-stats (0.5.3) - nap (~> 0.8) - cocoapods-trunk (0.6.1) - nap (>= 0.8) + cocoapods-stats (0.6.2) + cocoapods-trunk (0.6.4) + nap (>= 0.8, < 2.0) netrc (= 0.7.8) - cocoapods-try (0.4.5) + cocoapods-try (0.5.1) colored (1.2) escape (0.0.4) fuzzy_match (2.0.4) @@ -52,8 +52,8 @@ GEM metaclass (~> 0.0.1) mocha-on-bacon (0.2.2) mocha (>= 0.13.0) - molinillo (0.3.1) - nap (0.8.0) + molinillo (0.4.0) + nap (1.0.0) netrc (0.7.8) prettybacon (0.0.2) bacon (~> 1.2) @@ -61,7 +61,7 @@ GEM thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) - xcodeproj (0.26.3) + xcodeproj (0.28.2) activesupport (>= 3) claide (~> 0.9.1) colored (~> 1.2) @@ -77,3 +77,6 @@ DEPENDENCIES mocha-on-bacon prettybacon rake + +BUNDLED WITH + 1.10.6 diff --git a/lib/cocoapods-search/command/search.rb b/lib/cocoapods-search/command/search.rb index 044c979..514eb44 100644 --- a/lib/cocoapods-search/command/search.rb +++ b/lib/cocoapods-search/command/search.rb @@ -13,26 +13,37 @@ 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)'], - ['--ios', 'Restricts the search to Pods supported on iOS'], - ['--osx', 'Restricts the search to Pods supported on OS X'], - ['--watchos', 'Restricts the search to Pods supported on Watch OS'], ['--web', 'Searches on cocoapods.org'], - ].concat(super.reject { |option, _| option == '--silent' }) + ] + options += all_platforms.map do |platform| + ["--#{platform}", "Restricts the search to Pods supported on #{platform}"] + end + options.concat(super.reject { |option, _| option == '--silent' }) end def initialize(argv) @use_regex = argv.flag?('regex') @full_text_search = argv.flag?('full') @stats = argv.flag?('stats') - @supported_on_ios = argv.flag?('ios') - @supported_on_osx = argv.flag?('osx') - @supported_on_watchos = argv.flag?('watchos') @web = argv.flag?('web') + @platform_filters = all_platforms.map do |platform| + argv.flag?(platform) ? platform.to_sym : nil + end.compact @query = argv.arguments! unless argv.arguments.empty? config.silent = false super @@ -61,12 +72,11 @@ def run end def web_search - query_parameter = [ - ('on:osx' if @supported_on_osx), - ('on:ios' if @supported_on_ios), - ('on:watchos' if @supported_on_watchos), - @query, - ].compact.flatten.join(' ') + queries = @platform_filters.map do |platform| + "on:#{platform}" + end + queries += @query + query_parameter = queries.compact.flatten.join(' ') url = "https://cocoapods.org/?q=#{CGI.escape(query_parameter).gsub('+', '%20')}" UI.puts("Opening #{url}") open!(url) @@ -78,17 +88,12 @@ def local_search }.join(' ').strip sets = SourcesManager.search_by_name(query_regex, @full_text_search) - if @supported_on_ios - sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:ios) } - end - if @supported_on_osx - sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:osx) } - end - if @supported_on_watchos - sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(:watchos) } + + @platform_filters.each do |platform| + sets.reject! { |set| !set.specification.available_platforms.map(&:name).include?(platform) } end - sets.each do |set| + sets.each do |set| begin if @stats UI.pod(set, :stats) diff --git a/spec/command/search_spec.rb b/spec/command/search_spec.rb index 8bf595a..08be6b5 100644 --- a/spec/command/search_spec.rb +++ b/spec/command/search_spec.rb @@ -60,6 +60,12 @@ module Pod output.should.not.include? 'BananaLib' end + it 'restricts the search to Pods supported on tvOS' do + output = run_command('search', '', '--tvos') + output.should.include? 'monkey' + output.should.not.include? 'BananaLib' + end + it 'outputs with the silent parameter' do output = run_command('search', 'BananaLib', '--silent') output.should.include? 'BananaLib' @@ -115,6 +121,22 @@ module Pod run_command('search', '--web', '--ios', 'bananalib') end + it 'includes option --watchos correctly' do + Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Awatchos%20bananalib') + run_command('search', '--web', '--watchos', 'bananalib') + end + + it 'includes option --tvos correctly' do + Command::Search.any_instance.expects(:open!).with('https://cocoapods.org/?q=on%3Atvos%20bananalib') + run_command('search', '--web', '--tvos', 'bananalib') + end + + it 'includes any new platform option correctly' do + Command::Search.any_instance.stubs(:all_platforms).returns(%w(ios osx watchos tvos 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') run_command('search', '--web', '--ios', '--osx', 'bananalib') From 1ea058014c01ed170a4c50f2ff67747c86028279 Mon Sep 17 00:00:00 2001 From: Muhammed Yavuz Nuzumlali Date: Fri, 30 Oct 2015 19:19:22 +0300 Subject: [PATCH 2/3] Move all platforms logic to Core. --- CHANGELOG.md | 4 ++-- lib/cocoapods-search/command/search.rb | 18 ++++-------------- spec/command/search_spec.rb | 6 +++--- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8acdd2e..4605c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/cocoapods-search/command/search.rb b/lib/cocoapods-search/command/search.rb index 514eb44..0c30922 100644 --- a/lib/cocoapods-search/command/search.rb +++ b/lib/cocoapods-search/command/search.rb @@ -13,16 +13,6 @@ 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'], @@ -30,8 +20,8 @@ def self.options ['--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 @@ -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 diff --git a/spec/command/search_spec.rb b/spec/command/search_spec.rb index 08be6b5..88ea37a 100644 --- a/spec/command/search_spec.rb +++ b/spec/command/search_spec.rb @@ -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 From b984b000125bfc9a790071087d34d6ffec92b627 Mon Sep 17 00:00:00 2001 From: Muhammed Yavuz Nuzumlali Date: Sat, 31 Oct 2015 01:53:04 +0300 Subject: [PATCH 3/3] Point Gemfile to HEAD versions of cocoapods and core --- Gemfile | 3 ++- Gemfile.lock | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index a567fc4..0f7f267 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,8 @@ source 'https://rubygems.org' gemspec group :development do - gem 'cocoapods' + gem 'cocoapods', :git => "https://github.com/CocoaPods/CocoaPods.git", :branch => 'master' + gem 'cocoapods-core', :git => "https://github.com/CocoaPods/Core.git", :branch => 'master' gem 'bacon' gem 'mocha-on-bacon' gem 'prettybacon' diff --git a/Gemfile.lock b/Gemfile.lock index ae26ad6..799d927 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,19 +1,8 @@ -PATH - remote: . - specs: - cocoapods-search (0.1.0) - -GEM - remote: https://rubygems.org/ +GIT + remote: https://github.com/CocoaPods/CocoaPods.git + revision: f7578085842f7a8caca5d8ebbbd99f91a6474e45 + branch: master specs: - activesupport (4.2.3) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) - tzinfo (~> 1.1) - bacon (1.2.0) - claide (0.9.1) cocoapods (0.39.0) activesupport (>= 4.0.2) claide (~> 0.9.1) @@ -29,10 +18,33 @@ GEM molinillo (~> 0.4.0) nap (~> 1.0) xcodeproj (~> 0.28.2) + +GIT + remote: https://github.com/CocoaPods/Core.git + revision: ce26e1eb797a6ad1f1d94b0304a50c491bc41237 + branch: master + specs: cocoapods-core (0.39.0) activesupport (>= 4.0.2) fuzzy_match (~> 2.0.4) nap (~> 1.0) + +PATH + remote: . + specs: + cocoapods-search (0.1.0) + +GEM + remote: https://rubygems.org/ + specs: + activesupport (4.2.4) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + bacon (1.2.0) + claide (0.9.1) cocoapods-downloader (0.9.3) cocoapods-plugins (0.4.2) nap @@ -72,7 +84,8 @@ PLATFORMS DEPENDENCIES bacon bundler (~> 1.3) - cocoapods + cocoapods! + cocoapods-core! cocoapods-search! mocha-on-bacon prettybacon