Class: Kubes::Hooks::Runner

Inherits:
Object
  • Object
show all
Includes:
Logging, Util::Sh
Defined in:
lib/kubes/hooks/runner.rb

Instance Method Summary collapse

Methods included from Logging

#logger

Methods included from Util::Sh

#sh, #sh_capture

Constructor Details

#initialize(hook) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
# File 'lib/kubes/hooks/runner.rb', line 6

def initialize(hook)
  @hook = hook
  @execute = @hook["execute"]
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/kubes/hooks/runner.rb', line 11

def run
  case @execute
  when String
    sh(@execute, exit_on_fail: @hook["exit_on_fail"])
  when -> (e) { e.respond_to?(:public_instance_methods) && e.public_instance_methods.include?(:call) }
    @execute.new.call
  else
    @execute.call
  end
end