Class: GemCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(command_name, *args) ⇒ GemCommand

Returns a new instance of GemCommand.



4
5
6
7
8
9
10
11
12
13
# File 'lib/gem_command.rb', line 4

def initialize command_name, *args
  # require command class
  require File.join 'rubygems/commands', 
                    command_name.gsub(/(.)([A-Z])/,'\1_\2').downcase

  # initialize
  command = command_class(command_name).new
  command.instance_variable_set '@options', args: args
  command.execute    
end

Instance Method Details

#command_class(command_name) ⇒ Object



15
16
17
# File 'lib/gem_command.rb', line 15

def command_class command_name
  eval [Gem::Commands, command_name].join '::'
end