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:



16
17
18
19
20
# File 'lib/kitchen/lifecycle_hook/base.rb', line 16

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

Instance Attribute Details

#hookObject (readonly)

return [Hash]



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

def hook
  @hook
end

#lifecycle_hooksKitchen::LifecycleHooks (readonly)



5
6
7
# File 'lib/kitchen/lifecycle_hook/base.rb', line 5

def lifecycle_hooks
  @lifecycle_hooks
end

#phaseObject (readonly)

return [String]



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

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



41
42
43
# File 'lib/kitchen/lifecycle_hook/base.rb', line 41

def logger
  lifecycle_hooks.send(:logger)
end

#runObject

return [void]

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/kitchen/lifecycle_hook/base.rb', line 23

def run
  raise NotImplementedError
end

#should_run?TrueClass, FalseClass

Returns:

  • (TrueClass, FalseClass)


28
29
30
31
32
33
34
35
36
# File 'lib/kitchen/lifecycle_hook/base.rb', line 28

def should_run?
  if !includes.empty?
    includes.include?(platform_name)
  elsif !excludes.empty?
    !excludes.include?(platform_name)
  else
    true
  end
end