Sha256: 488c9c9f66b6135da9b7ee707186982c292e0297b760255afeaeb8c081a32243

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

module Rails
  module Sh
    module Command
      class << self
        def commands
          @commands ||= {}
        end

        def define(name, &block)
          commands[name.to_sym] = block
        end

        def find(line)
          if name = line.split(/\s+/, 2)[0]
            commands[name.to_sym]
          else
            nil
          end
        end

        def command_names
          commands.keys
        end

        def [](name)
          commands[name]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-sh-1.2.3 lib/rails/sh/command.rb
rails-sh-1.2.2 lib/rails/sh/command.rb
rails-sh-1.2.0 lib/rails/sh/command.rb