Parse block trigger configs
This commit is contained in:
parent
6f00eb5679
commit
e0a5b1d647
|
@ -32,8 +32,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
command.each do |cmd|
|
command.each do |cmd|
|
||||||
trigger = VagrantConfigTrigger.new(cmd)
|
trigger = create_trigger(cmd, blk)
|
||||||
trigger.add_config(blk)
|
|
||||||
@_before_triggers << trigger
|
@_before_triggers << trigger
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -42,7 +41,7 @@ module VagrantPlugins
|
||||||
# trigger
|
# trigger
|
||||||
#
|
#
|
||||||
# @param [Symbol] command Vagrant command to create trigger on
|
# @param [Symbol] command Vagrant command to create trigger on
|
||||||
# @param [Block] block The defined before block
|
# @param [Block] block The defined after block
|
||||||
def after(*command, &block)
|
def after(*command, &block)
|
||||||
blk = block
|
blk = block
|
||||||
if !block_given? && command.last.is_a?(Hash)
|
if !block_given? && command.last.is_a?(Hash)
|
||||||
|
@ -55,8 +54,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
command.each do |cmd|
|
command.each do |cmd|
|
||||||
trigger = VagrantConfigTrigger.new(cmd)
|
trigger = create_trigger(cmd, blk)
|
||||||
trigger.add_config(blk)
|
|
||||||
@_after_triggers << trigger
|
@_after_triggers << trigger
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,6 +63,19 @@ module VagrantPlugins
|
||||||
# Internal methods, don't call these.
|
# Internal methods, don't call these.
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
# @param [Symbol] command Vagrant command to create trigger on
|
||||||
|
# @param [Block] block The defined config block
|
||||||
|
def create_trigger(command, block)
|
||||||
|
trigger = VagrantConfigTrigger.new(cmd)
|
||||||
|
if block.is_a?(Hash)
|
||||||
|
trigger.set_options(block)
|
||||||
|
else
|
||||||
|
block.call(trigger, VagrantConfigTrigger)
|
||||||
|
end
|
||||||
|
trigger.finalize!
|
||||||
|
return trigger
|
||||||
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
# read through configured settings blocks and set their values
|
# read through configured settings blocks and set their values
|
||||||
# and then set up action hooks here?
|
# and then set up action hooks here?
|
||||||
|
|
|
@ -79,15 +79,9 @@ module VagrantPlugins
|
||||||
@command = command.to_sym
|
@command = command.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
# Expecting a ruby block of a trigger config
|
#-------------------------------------------------------------------
|
||||||
def add_config(config_block)
|
# Internal methods, don't call these.
|
||||||
if config_block.is_a?(Hash)
|
#-------------------------------------------------------------------
|
||||||
# We have a ruby hash
|
|
||||||
self.set_options(config_block)
|
|
||||||
else
|
|
||||||
# We have a ruby block
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
# Ensure all config options are set to nil if untouched by user
|
# Ensure all config options are set to nil if untouched by user
|
||||||
|
|
Loading…
Reference in New Issue