Class: CommandLoader

Inherits:
Object show all
Defined in:
lib/maws/command_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ CommandLoader

Returns a new instance of CommandLoader.



2
3
4
# File 'lib/maws/command_loader.rb', line 2

def initialize(config)
  @config = config
end

Instance Method Details

#loadObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/maws/command_loader.rb', line 6

def load
  # assumes command file is known to exist already
  @config.command_name = @config.command_line.command_name
  command_path = @config.config.available_commands[@config.command_name]
  class_constant_name = constantize_file_name(@config.command_name)

  require command_path

  begin
    @config.command_class = Object.const_get(class_constant_name)
  rescue NameError
    error "Could not load class #{class_constant_name} from the file #{command_path}"
    exit(1)
  end
end