diff --git a/lib/vagrant.rb b/lib/vagrant.rb index e3b56fccd..17049d6cc 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -8,7 +8,7 @@ PROJECT_ROOT = File.join(libdir, '..') unless defined?(PROJECT_ROOT) end # The vagrant specific files which must be loaded prior to the rest -%w{vagrant/util vagrant/stacked_proc_runner vagrant/actions/base vagrant/downloaders/base vagrant/actions/collection +%w{vagrant/util vagrant/util/stacked_proc_runner vagrant/actions/base vagrant/downloaders/base vagrant/actions/collection vagrant/actions/runner vagrant/config vagrant/provisioners/base vagrant/provisioners/chef}.each do |f| require File.expand_path(f, libdir) end diff --git a/lib/vagrant/config.rb b/lib/vagrant/config.rb index f0ddbc884..903ca6c7b 100644 --- a/lib/vagrant/config.rb +++ b/lib/vagrant/config.rb @@ -4,7 +4,7 @@ module Vagrant end class Config - extend StackedProcRunner + extend Util::StackedProcRunner @@config = nil @@ -66,7 +66,7 @@ module Vagrant end class VMConfig < Base - include StackedProcRunner + include Util::StackedProcRunner attr_accessor :box attr_accessor :box_ovf diff --git a/lib/vagrant/stacked_proc_runner.rb b/lib/vagrant/stacked_proc_runner.rb deleted file mode 100644 index 0741f5878..000000000 --- a/lib/vagrant/stacked_proc_runner.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Vagrant - # Represents the "stacked proc runner" behavior which is used a - # couple places within Vagrant. This allows procs to "stack" on - # each other, then all execute in a single action. An example of - # its uses can be seen in the {Config} class. - module StackedProcRunner - # Returns the proc stack. This should always be called as the - # accessor of the stack. The instance variable itself should _never_ - # be used. - # - # @return [Array] - def proc_stack - @_proc_stack ||= [] - end - - # Adds (pushes) a proc to the stack. The actual proc added here is - # not executed, but merely stored. - # - # @param [Proc] block - def push_proc(&block) - proc_stack << block - end - - # Executes all the procs on the stack, passing in the given arguments. - # The stack is not cleared afterwords. It is up to the user of this - # mixin to clear the stack by calling `proc_stack.clear`. - def run_procs!(*args) - proc_stack.each do |proc| - proc.call(*args) - end - end - end -end \ No newline at end of file diff --git a/lib/vagrant/util/stacked_proc_runner.rb b/lib/vagrant/util/stacked_proc_runner.rb new file mode 100644 index 000000000..f34fd5e81 --- /dev/null +++ b/lib/vagrant/util/stacked_proc_runner.rb @@ -0,0 +1,35 @@ +module Vagrant + module Util + # Represents the "stacked proc runner" behavior which is used a + # couple places within Vagrant. This allows procs to "stack" on + # each other, then all execute in a single action. An example of + # its uses can be seen in the {Config} class. + module StackedProcRunner + # Returns the proc stack. This should always be called as the + # accessor of the stack. The instance variable itself should _never_ + # be used. + # + # @return [Array] + def proc_stack + @_proc_stack ||= [] + end + + # Adds (pushes) a proc to the stack. The actual proc added here is + # not executed, but merely stored. + # + # @param [Proc] block + def push_proc(&block) + proc_stack << block + end + + # Executes all the procs on the stack, passing in the given arguments. + # The stack is not cleared afterwords. It is up to the user of this + # mixin to clear the stack by calling `proc_stack.clear`. + def run_procs!(*args) + proc_stack.each do |proc| + proc.call(*args) + end + end + end + end +end \ No newline at end of file diff --git a/test/vagrant/config_test.rb b/test/vagrant/config_test.rb index bf5b519bc..47db91909 100644 --- a/test/vagrant/config_test.rb +++ b/test/vagrant/config_test.rb @@ -205,7 +205,7 @@ class ConfigTest < Test::Unit::TestCase end should "include the stacked proc runner module" do - assert @config.class.included_modules.include?(Vagrant::StackedProcRunner) + assert @config.class.included_modules.include?(Vagrant::Util::StackedProcRunner) end should "add the customize proc to the proc stack" do diff --git a/test/vagrant/stacked_proc_runner_test.rb b/test/vagrant/util/stacked_proc_runner_test.rb similarity index 85% rename from test/vagrant/stacked_proc_runner_test.rb rename to test/vagrant/util/stacked_proc_runner_test.rb index 6202de90c..687d311c8 100644 --- a/test/vagrant/stacked_proc_runner_test.rb +++ b/test/vagrant/util/stacked_proc_runner_test.rb @@ -1,8 +1,8 @@ -require File.join(File.dirname(__FILE__), '..', 'test_helper') +require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') -class StackedProcRunnerTest < Test::Unit::TestCase +class StackedProcRunnerUtilTest < Test::Unit::TestCase class TestClass - include Vagrant::StackedProcRunner + include Vagrant::Util::StackedProcRunner end setup do