Class: Kitchen::LifecycleHooks

Inherits:
Object
  • Object
show all
Includes:
Configurable, Logging, ShellOut
Defined in:
lib/kitchen/lifecycle_hooks.rb

Overview

A helper object used by Instance to coordinate lifecycle hook calls from the `lifecycle:` configuration section.

Since:

  • 1.22

Instance Attribute Summary

Attributes included from Configurable

#instance

Instance Method Summary collapse

Methods included from ShellOut

#run_command

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) ⇒ LifecycleHooks

Returns a new instance of LifecycleHooks.

Since:

  • 1.22


32
33
34
# File 'lib/kitchen/lifecycle_hooks.rb', line 32

def initialize(config)
  init_config(config)
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.

Parameters:

  • phase (String)

    Lifecycle phase which is being executed.

  • state_file (StateFile)

    Instance state file object.

  • block (Proc)

    Block of code implementing the lifecycle phase.

Since:

  • 1.22


42
43
44
45
46
# File 'lib/kitchen/lifecycle_hooks.rb', line 42

def run_with_hooks(phase, state_file, &block)
  run(instance, phase, state_file, :pre)
  yield
  run(instance, phase, state_file, :post)
end