Class: Gem::Commands::DocCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/doc_command.rb

Instance Method Summary collapse

Constructor Details

#initializeDocCommand

Returns a new instance of DocCommand.



4
5
6
# File 'lib/rubygems/commands/doc_command.rb', line 4

def initialize
  super 'doc', 'Open gem rdoc'
end

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rubygems/commands/doc_command.rb', line 8

def execute
  index = Gem::SourceIndex.from_installed_gems
  spec = index.find_name(get_one_gem_name, Gem::Requirement.default).last

  if spec.has_rdoc?
    exec 'open', File.join(spec.installation_path, 'doc', spec.full_name, 'rdoc', 'index.html')
  else
    $stderr.puts "#{spec.full_name} does not have rdoc."
  end

  def usage
    "#{program_name} GEMNAME"
  end
end

#usageObject



18
19
20
# File 'lib/rubygems/commands/doc_command.rb', line 18

def usage
  "#{program_name} GEMNAME"
end