Commit beb588a9 authored by Fabio Pelosin's avatar Fabio Pelosin

[Command::Search] Add support for `--ios` and `--osx`

Closes #625
parent 7117139f
......@@ -13,6 +13,12 @@
non-integrating installations.
[#918](https://github.com/CocoaPods/CocoaPods/issues/918)
###### Ancillary enhancements
* The `pod search` commands now accepts the `--ios` and the `--osx` arguments
to filter the results by platform.
[#625](https://github.com/CocoaPods/CocoaPods/issues/625)
## 0.17.2
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.17.1...0.17.2)
......
......@@ -14,13 +14,17 @@ module Pod
def self.options
[[
"--full", "Search by name, summary, and description",
"--stats", "Show additional stats (like GitHub watchers and forks)"
"--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",
]].concat(super)
end
def initialize(argv)
@full_text_search = argv.flag?('full')
@stats = argv.flag?('stats')
@supported_on_ios = argv.flag?('ios')
@supported_on_osx = argv.flag?('osx')
@query = argv.shift_argument
super
end
......@@ -32,10 +36,16 @@ module Pod
def run
sets = SourcesManager.search_by_name(@query.strip, @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
sets.each do |set|
begin
UI.pod(set, (@stats ? :stats : :normal))
rescue DSLError => e
rescue DSLError
UI.warn "Skipping `#{set.name}` because the podspec contains errors."
end
end
......
......@@ -5,6 +5,8 @@ Pod::Spec.new do |s|
s.homepage = 'http://banana-corp.local/banana-lib.html'
s.summary = 'Chunky bananas!'
s.description = 'Full of chunky bananas.'
s.platform = :ios
s.source = { :git => 'http://banana-corp.local/banana-lib.git', :tag => 'v1.0' }
s.source_files = 'Classes/*.{h,m}', 'Vendor'
s.xcconfig = { 'OTHER_LDFLAGS' => '-framework SystemConfiguration' }
......
......@@ -31,5 +31,18 @@ module Pod
output = run_command('search', 'Engelhart', '--full')
output.should.include? 'JSONKit'
end
it "restricts the search to Pods supported on iOS" do
output = run_command('search', 'BananaLib', '--ios')
output.should.include? 'BananaLib'
Specification.any_instance.stubs(:available_platforms).returns([Platform.osx])
output = run_command('search', 'BananaLib', '--ios')
output.should.not.include? 'BananaLib'
end
it "restricts the search to Pods supported on iOS" do
output = run_command('search', 'BananaLib', '--osx')
output.should.not.include? 'BananaLib'
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment