Sha256: c0e1a1b81826b08585f00199017680788aaf6baad4ae0073bd0831626042a7a9

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'relish'
require 'relish/helpers'
require 'relish/error_messages'
require 'relish/resource_methods'
require 'relish/commands/base'
require 'relish/commands/collab'
require 'relish/commands/config'
require 'relish/commands/help'
require 'relish/commands/projects'
require 'relish/commands/push'
require 'relish/commands/versions'

module Relish
  module Command
    
    class << self
      include Relish::Helpers
      
      def run(command, args)
        command_class, method = get_command_and_method(command, args)      
        command_class.new(args).send(method)
      end
    
      def get_command_and_method(command, args)
        command_class, method = command.split(':')
        return get_command(command_class.capitalize), get_method(method)
      rescue NameError
        error :unknown_command
      end
      
    private
    
      def get_command(command)
        Relish::Command.const_get(command)
      end
      
      def get_method(method)
        method || :default
      end
      
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
relish-0.1.5 lib/relish/command.rb
relish-0.1.4 lib/relish/command.rb