Class: Gem::Commands::OpenCommand

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

Instance Method Summary collapse

Constructor Details

#initializeOpenCommand

Returns a new instance of OpenCommand.



2
3
4
# File 'lib/rubygems/commands/cd.rb', line 2

def initialize
  super 'cd', "Navigates to the gem's source directory."
end

Instance Method Details

#argumentsObject



6
7
8
# File 'lib/rubygems/commands/cd.rb', line 6

def arguments
  "GEM       gem name"
end

#executeObject

Raises:

  • (Gem::CommandLineError)


10
11
12
13
14
15
# File 'lib/rubygems/commands/cd.rb', line 10

def execute
  gem = options[:args].first
  raise Gem::CommandLineError, 'Usage: gem cd GEM' unless gem
  Dir.chdir("#{Gem::Specification.find_by_name(gem).full_gem_path}")
  exec '$0'
end