Class: VagrantPlugins::Exec::CommandConstructor
- Inherits:
-
Object
- Object
- VagrantPlugins::Exec::CommandConstructor
- Defined in:
- lib/vagrant-exec/support/command_constructor.rb
Instance Method Summary collapse
- #construct_command ⇒ Object
-
#initialize(command, config) ⇒ CommandConstructor
constructor
A new instance of CommandConstructor.
Constructor Details
#initialize(command, config) ⇒ CommandConstructor
Returns a new instance of CommandConstructor.
5 6 7 8 |
# File 'lib/vagrant-exec/support/command_constructor.rb', line 5 def initialize(command, config) @command = command.dup @config = config end |
Instance Method Details
#construct_command ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant-exec/support/command_constructor.rb', line 10 def construct_command ''.tap do |constructed_command| # directory is applied only once in the beginning @config.reverse.each do |command| if command_matches?(command[:cmd], @command) && !directory_added? constructed_command << add_directory(command[:opts][:directory]) end end # apply environment variables @config.each do |command| if command_matches?(command[:cmd], @command) constructed_command << add_env(command[:opts][:env]) end end # apply prepend in the end @config.each do |command| if command_matches?(command[:cmd], @command) constructed_command << add_prepend(command[:opts][:prepend]) end end constructed_command << @command end end |