Class: VagrantSandbox::Middleware
- Inherits:
-
Object
- Object
- VagrantSandbox::Middleware
- Defined in:
- lib/vagrant-sandbox/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, env) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 8 |
# File 'lib/vagrant-sandbox/middleware.rb', line 5 def initialize(app, env) @app = app @env = env end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-sandbox/middleware.rb', line 10 def call(env) if env["vm"].created? && env["vm"].vm.running? command = "sandbox #{env["sandbox.command"]}".strip env["vm"].ssh.execute do |ssh| env.ui.info I18n.t("vagrant.plugins.sandbox.executing", :command => command) ssh.exec!("cd /home/vagrant; #{command}") do |channel, type, data| $stdout.print(data) if type != :exit_status end $stdout.puts end end @app.call(env) end |