Action runner supports global parameters
This commit is contained in:
parent
bbb8f0ac2c
commit
b31c3d458c
|
@ -11,8 +11,9 @@ module Vagrant
|
||||||
class Runner
|
class Runner
|
||||||
@@reported_interrupt = false
|
@@reported_interrupt = false
|
||||||
|
|
||||||
def initialize(registry)
|
def initialize(registry, globals=nil)
|
||||||
@registry = registry
|
@registry = registry
|
||||||
|
@globals = globals || {}
|
||||||
@logger = Log4r::Logger.new("vagrant::action::runner")
|
@logger = Log4r::Logger.new("vagrant::action::runner")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ module Vagrant
|
||||||
|
|
||||||
# Create the initial environment with the options given
|
# Create the initial environment with the options given
|
||||||
environment = Environment.new
|
environment = Environment.new
|
||||||
|
environment.merge!(@globals)
|
||||||
environment.merge!(options || {})
|
environment.merge!(options || {})
|
||||||
|
|
||||||
# Run the action chain in a busy block, marking the environment as
|
# Run the action chain in a busy block, marking the environment as
|
||||||
|
|
|
@ -40,4 +40,15 @@ describe Vagrant::Action::Runner do
|
||||||
instance.run(callable, "data" => "foo")
|
instance.run(callable, "data" => "foo")
|
||||||
result.should == "foo"
|
result.should == "foo"
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue