Class: Pod::Command::Browser

Inherits:
Pod::Command show all
Extended by:
Executable
Defined in:
lib/pod/command/browser.rb

Class Method Summary collapse

Instance Method Summary collapse

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')
  @names = argv.arguments! unless argv.arguments.empty?
  super
end

Class Method Details

.optionsObject



12
13
14
15
16
# File 'lib/pod/command/browser.rb', line 12

def self.options
  [
    [ '--spec', 'Open the podspec in the browser. github.com/tree/master/[NAME].podspec' ],
  ].concat(super)
end

Instance Method Details

#pick_open_url(spec) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/pod/command/browser.rb', line 61

def pick_open_url(spec)
  url = spec.homepage
  if @spec && url =~ %r|^https?://github.com/|
    "%s/tree/master/%s.podspec" % [ url, spec.name ]
  else
    url
  end
end

#runObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pod/command/browser.rb', line 32

def run
#         update_specs_repos
  @names.each do |name|
    if spec = spec_with_name(name)
      UI.title "Opening #{spec.name}" do
        url = pick_open_url(spec)
        UI.puts(">>> #{url}")
        open!(url)
      end
    end
  end
end

#spec_with_name(name) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/pod/command/browser.rb', line 53

def spec_with_name(name)
  if set = SourcesManager.search(Dependency.new(name))
    set.specification.root
  else
    raise Informative, "Unable to find a podspec named `#{name}`"
  end
end

#update_specs_reposObject



45
46
47
48
49
50
51
# File 'lib/pod/command/browser.rb', line 45

def update_specs_repos
  unless config.skip_repo_update?
    UI.section 'Updating spec repositories' do
      SourcesManager.update
    end
  end
end

#validate!Object



24
25
26
27
# File 'lib/pod/command/browser.rb', line 24

def validate!
  super
  help! 'A Pod name is required' unless @names
end