Class: Gem::Commands::VisitCommand

Inherits:
Gem::Command
  • Object
show all
Includes:
VersionOption, GemToolbox::CommonOptions
Defined in:
lib/rubygems/commands/visit_command.rb

Overview

VisitCommand opens the gem’s homepage in a browser

Instance Method Summary collapse

Methods included from GemToolbox::CommonOptions

#add_command_option, #add_exact_match_option, #add_latest_version_option, #get_path, #get_spec, #show

Constructor Details

#initializeVisitCommand

Returns a new instance of VisitCommand.



9
10
11
12
13
14
15
16
17
18
# File 'lib/rubygems/commands/visit_command.rb', line 9

def initialize
  super "readme", "Visit gem's homepage in a browser",
    :command => nil, 
    :version => Gem::Requirement.default,
    :latest  => false
  
  add_latest_version_option
  add_exact_match_option
  add_version_option
end

Instance Method Details

#argumentsObject

:nodoc:



20
21
22
# File 'lib/rubygems/commands/visit_command.rb', line 20

def arguments # :nodoc:
  "GEMNAME      Gem to visit"
end

#executeObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rubygems/commands/visit_command.rb', line 24

def execute
  name = get_one_gem_name
  spec = get_spec(name)    
  
  if spec.homepage
    #Launchy::Browser.run(spec.homepage)
    Launchy.open(spec.homepage)
  else
    say "Homepage not defined for #{name}"
  end
end