Sha256: ae0df382164b341d3d4f71aeba8d73dbc2cfdac60f8956e285c917b27941af10

Contents?: true

Size: 528 Bytes

Versions: 1

Compression:

Stored size: 528 Bytes

Contents

module Carrasco
  class CommandBuilder
    def from_config(config)
      klass = Class.new(Thor)

      config['commands'].each do |method, options|
        command = Command.new(method, options)
        inject_command_into_class(command, klass)
      end

      klass
    end

    def inject_command_into_class(command, klass)
      klass.desc(command.help, command.description)
      klass.class_eval do
        define_method(command.command_name) do
          execute_command(command)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
carrasco-0.1.5 lib/carrasco/command_builder.rb