Class: Pod::Command::Browser
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Browser
- Extended by:
- Executable
- Defined in:
- lib/pod/command/browser.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Browser
constructor
A new instance of Browser.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Browser
Returns a new instance of Browser.
18 19 20 21 22 |
# File 'lib/pod/command/browser.rb', line 18 def initialize(argv) @spec = argv.flag?('spec') @query = argv.arguments! unless argv.arguments.empty? super end |
Class Method Details
.options ⇒ Object
12 13 14 15 16 |
# File 'lib/pod/command/browser.rb', line 12 def self. [ '--spec', 'Open the podspec on the browser. github.com/tree/master/[PODNAME].podspec', ].concat(super) end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pod/command/browser.rb', line 32 def run @query.each do |query| opened = false sets = SourcesManager.search_by_name(query.strip, false) 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 `#{pod.name}` because the homepage not found." end rescue DSLError UI.warn "Skipping `#{pod.name}` because the podspec contains errors." end end UI.warn "The query(`#{query}`) not found pod." unless opened end end |
#validate! ⇒ Object
24 25 26 27 |
# File 'lib/pod/command/browser.rb', line 24 def validate! super help! "A search query is required." unless @query end |