Class: LunarShell::Middleware::Interpreter
- Inherits:
-
Object
- Object
- LunarShell::Middleware::Interpreter
- Defined in:
- lib/lunar_shell/middleware/interpreter.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Interpreter
constructor
A new instance of Interpreter.
Constructor Details
#initialize(app, options = {}) ⇒ Interpreter
Returns a new instance of Interpreter.
4 5 6 |
# File 'lib/lunar_shell/middleware/interpreter.rb', line 4 def initialize(app, = {}) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lunar_shell/middleware/interpreter.rb', line 8 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 |