Class: Kitchen::LifecycleHook::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/lifecycle_hook/base.rb

Direct Known Subclasses

Local, Remote

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lifecycle_hooks, phase, hook) ⇒ Base

Returns a new instance of Base.

Parameters:



18
19
20
21
22
# File 'lib/kitchen/lifecycle_hook/base.rb', line 18

def initialize(lifecycle_hooks, phase, hook)
  @lifecycle_hooks = lifecycle_hooks
  @phase = phase
  @hook = hook
end

Instance Attribute Details

#hookObject (readonly)

return [Hash]



13
14
15
# File 'lib/kitchen/lifecycle_hook/base.rb', line 13

def hook
  @hook
end

#lifecycle_hooksKitchen::LifecycleHooks (readonly)



7
8
9
# File 'lib/kitchen/lifecycle_hook/base.rb', line 7

def lifecycle_hooks
  @lifecycle_hooks
end

#phaseObject (readonly)

return [String]



10
11
12
# File 'lib/kitchen/lifecycle_hook/base.rb', line 10

def phase
  @phase
end

Instance Method Details

#loggerLogger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the lifecycle hooks’s logger otherwise.

Returns:

  • (Logger)

    the lifecycle hooks’s logger otherwise



43
44
45
# File 'lib/kitchen/lifecycle_hook/base.rb', line 43

def logger
  lifecycle_hooks.send(:logger)
end

#runObject

return [void]

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/kitchen/lifecycle_hook/base.rb', line 25

def run
  raise NotImplementedError
end

#should_run?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


30
31
32
33
34
35
36
37
38
# 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