Class: Skunk::CommandFactory

Inherits:
RubyCritic::CommandFactory
  • Object
show all
Defined in:
lib/skunk/command_factory.rb

Overview

Knows how to calculate the command that was request by the CLI user

Constant Summary collapse

COMMAND_CLASS_MODES =
%i[version help default compare].freeze

Class Method Summary collapse

Class Method Details

.command_class(mode) ⇒ Class

Returns the command class based on the command that was executed

Parameters:

  • mode

Returns:

  • (Class)


14
15
16
17
18
19
20
21
22
23
# File 'lib/skunk/command_factory.rb', line 14

def self.command_class(mode)
  mode = mode.to_s.split("_").first.to_sym
  if COMMAND_CLASS_MODES.include? mode
    require "skunk/commands/#{mode}"
    Command.const_get(mode.capitalize)
  else
    require "skunk/commands/default"
    Command::Default
  end
end