lib/pod/command/browser.rb in cocoapods-browser-0.0.2 vs lib/pod/command/browser.rb in cocoapods-browser-0.0.3
- old
+ new
@@ -7,11 +7,18 @@
Opens the homepage on browser.
DESC
self.arguments = '[QUERY]'
+ def self.options
+ [
+ '--spec', 'Open the podspec on the browser. github.com/tree/master/[PODNAME].podspec',
+ ].concat(super)
+ end
+
def initialize(argv)
+ @spec = argv.flag?('spec')
@query = argv.arguments! unless argv.arguments.empty?
super
end
def validate!
@@ -29,18 +36,25 @@
statistics_provider = Config.instance.spec_statistics_provider
sets.each do |set|
begin
pod = Specification::Set::Presenter.new(set, statistics_provider)
next if query != pod.name
+
if url = pod.homepage
+ if @spec && url =~ %r|^https?://github.com/|
+ url << "/tree/master/#{pod.name}.podspec"
+ else
+ UI.warn "Skipping `#{pod.name}` because the homgepage is only `github.com`."
+ next
+ end
UI.puts("Opening #{url}")
open!(url)
opened = true
else
- UI.warn "Skipping `#{set.name}` because the homepage not found."
+ UI.warn "Skipping `#{pod.name}` because the homepage not found."
end
rescue DSLError
- UI.warn "Skipping `#{set.name}` because the podspec contains errors."
+ UI.warn "Skipping `#{pod.name}` because the podspec contains errors."
end
end
UI.warn "The query(`#{query}`) not found pod." unless opened
end
end