Class: Kitchen::LifecycleHooks
- Inherits:
-
Object
- Object
- Kitchen::LifecycleHooks
- Includes:
- Configurable, Logging
- Defined in:
- lib/kitchen/lifecycle_hooks.rb
Overview
A helper object used by Instance to coordinate lifecycle hook calls from the ‘lifecycle:` configuration section.
Instance Attribute Summary collapse
- #state_file ⇒ Kitchen::StateFile readonly
Attributes included from Configurable
Instance Method Summary collapse
-
#initialize(config, state_file) ⇒ LifecycleHooks
constructor
A new instance of LifecycleHooks.
-
#run_with_hooks(phase, state_file, &block) ⇒ void
Run a lifecycle phase with the pre and post hooks.
Methods included from Logging
#banner, #debug, #error, #fatal, #info, #warn
Methods included from Configurable
#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?
Constructor Details
#initialize(config, state_file) ⇒ LifecycleHooks
Returns a new instance of LifecycleHooks.
34 35 36 37 |
# File 'lib/kitchen/lifecycle_hooks.rb', line 34 def initialize(config, state_file) init_config(config) @state_file = state_file end |
Instance Attribute Details
#state_file ⇒ Kitchen::StateFile (readonly)
54 55 56 |
# File 'lib/kitchen/lifecycle_hooks.rb', line 54 def state_file @state_file end |
Instance Method Details
#run_with_hooks(phase, state_file, &block) ⇒ void
This method returns an undefined value.
Run a lifecycle phase with the pre and post hooks.
45 46 47 48 49 50 51 |
# File 'lib/kitchen/lifecycle_hooks.rb', line 45 def run_with_hooks(phase, state_file, &block) run(phase, :pre) yield run(phase, :post) ensure run(phase, :finally) end |