class Kitchen::LifecycleHook::Base

Attributes

hook[R]

return [Hash]

lifecycle_hooks[R]

@return [Kitchen::LifecycleHooks]

phase[R]

return [String]

Public Class Methods

new(lifecycle_hooks, phase, hook) click to toggle source

@param lifecycle_hooks [Kitchen::LifecycleHooks] @param phase [String] @param hook [Hash]

# File lib/kitchen/lifecycle_hook/base.rb, line 18
def initialize(lifecycle_hooks, phase, hook)
  @lifecycle_hooks = lifecycle_hooks
  @phase = phase
  @hook = hook
end

Public Instance Methods

logger() click to toggle source

@return [Logger] the lifecycle hooks's logger

otherwise

@api private

# File lib/kitchen/lifecycle_hook/base.rb, line 43
def logger
  lifecycle_hooks.send(:logger)
end
run() click to toggle source

return [void]

# File lib/kitchen/lifecycle_hook/base.rb, line 25
def run
  raise NotImplementedError
end
should_run?() click to toggle source

@return [TrueClass, FalseClass]

# File lib/kitchen/lifecycle_hook/base.rb, line 30
def should_run?
  if !includes.empty?
    includes.include?(platform_name)
  elsif !excludes.empty?
    !excludes.include?(platform_name)
  else
    true
  end
end

Private Instance Methods

config() click to toggle source

@return [Hash]

# File lib/kitchen/lifecycle_hook/base.rb, line 55
def config
  lifecycle_hooks.send(:config)
end
excludes() click to toggle source

@return [Array<PlatformFilter>] names of excluded platforms

# File lib/kitchen/lifecycle_hook/base.rb, line 65
def excludes
  @excludes ||= PlatformFilter.convert(hook.fetch(:excludes, []))
end
includes() click to toggle source

@return [Array<PlatformFilter>] names of only included platforms

# File lib/kitchen/lifecycle_hook/base.rb, line 70
def includes
  @includes ||= PlatformFilter.convert(hook.fetch(:includes, []))
end
instance() click to toggle source

@return [Kitchen::Instance]

# File lib/kitchen/lifecycle_hook/base.rb, line 50
def instance
  lifecycle_hooks.instance
end
platform_name() click to toggle source

@return [String]

# File lib/kitchen/lifecycle_hook/base.rb, line 75
def platform_name
  instance.platform.name
end
state_file() click to toggle source

@return [Kitchen::StateFile]

# File lib/kitchen/lifecycle_hook/base.rb, line 60
def state_file
  lifecycle_hooks.state_file
end