Sha256: dfc4c2f1e521111c60efbb3c97e64e98de1eb03234c073b62d997a5c33ee3940

Contents?: true

Size: 628 Bytes

Versions: 3

Compression:

Stored size: 628 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'] = LunarShell::Engine.run_command_path(command)
          end
        end

        @app.call(env)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lunar_shell-0.5.2 lib/lunar_shell/middleware/interpreter.rb
lunar_shell-0.5.0 lib/lunar_shell/middleware/interpreter.rb
lunar_shell-0.4.1 lib/lunar_shell/middleware/interpreter.rb