Sha256: 0a856c32d1ca8da884ebf03ad09ad23f44851300aab0aae0e68067c7e5f5d242

Contents?: true

Size: 500 Bytes

Versions: 1

Compression:

Stored size: 500 Bytes

Contents

require "thor"

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

      config['commands'].each do |method, options|
        help        = options.fetch('help')
        description = options.fetch('description')
        command     = options.fetch('command')

        klass.class_eval do
          desc help, description
          define_method (method) do
            system(command)
          end
        end
      end

      klass
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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