From b31c3d458c38abc052a7d619e0b7185c09e9ebc7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 9 Dec 2011 14:44:43 -0800 Subject: [PATCH] Action runner supports global parameters --- lib/vagrant/action/runner.rb | 4 +++- test/unit/vagrant/action/runner_test.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/runner.rb b/lib/vagrant/action/runner.rb index cf7db63eb..ba3833897 100644 --- a/lib/vagrant/action/runner.rb +++ b/lib/vagrant/action/runner.rb @@ -11,8 +11,9 @@ module Vagrant class Runner @@reported_interrupt = false - def initialize(registry) + def initialize(registry, globals=nil) @registry = registry + @globals = globals || {} @logger = Log4r::Logger.new("vagrant::action::runner") end @@ -24,6 +25,7 @@ module Vagrant # Create the initial environment with the options given environment = Environment.new + environment.merge!(@globals) environment.merge!(options || {}) # Run the action chain in a busy block, marking the environment as diff --git a/test/unit/vagrant/action/runner_test.rb b/test/unit/vagrant/action/runner_test.rb index 15f10013e..2a3e1d4cd 100644 --- a/test/unit/vagrant/action/runner_test.rb +++ b/test/unit/vagrant/action/runner_test.rb @@ -40,4 +40,15 @@ describe Vagrant::Action::Runner do instance.run(callable, "data" => "foo") result.should == "foo" end + + it "should pass global options into the hash" do + result = nil + callable = lambda do |env| + result = env["data"] + end + + instance = described_class.new(registry, "data" => "bar") + instance.run(callable) + result.should == "bar" + end end