Class: RubyCritic::CommandFactory

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

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.command_class(mode) ⇒ Object


14
15
16
17
18
19
20
21
22
23
# File 'lib/rubycritic/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 "rubycritic/commands/#{mode}"
    Command.const_get(mode.capitalize)
  else
    require 'rubycritic/commands/default'
    Command::Default
  end
end

.create(options = {}) ⇒ Object


9
10
11
12
# File 'lib/rubycritic/command_factory.rb', line 9

def self.create(options = {})
  Config.set(options)
  command_class(Config.mode).new(options)
end