Sha256: 6cab9e5720235fa4a5e505a4655e6b7afbacce81de9d1a85c8d61f172148023f

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

module LunarShell
  module Middleware
    class Interpreter
      def initialize(app, options = {})
        @app = app
      end

      def call(env)
        request = Rack::Request.new(env)

        if (input = request.delete_param('command_line')).present?
          params = input.split(' ')
          command = params.shift

          if command
            request.update_param('parameters', params) if params.any?
            request.update_param('command', command)

            env['PATH_INFO'] = "/satellites/#{command}/run"
          end
        end

        @app.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lunar_shell-0.3.0 lib/lunar_shell/middleware/interpreter.rb