Sha256: 46d835074a5f92ad56c8519e936e9fdbe40078021269a44c7d544e1c6e9569fa

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

require "rubycritic/command_factory"

module Skunk
  # Knows how to calculate the command that was request by the CLI user
  class CommandFactory < RubyCritic::CommandFactory
    COMMAND_CLASS_MODES = %i[version help default compare].freeze

    # Returns the command class based on the command that was executed
    #
    # @param mode
    # @return [Class]
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skunk-0.5.3 lib/skunk/command_factory.rb