Class: Henk::Instance
Instance Method Summary
collapse
Methods included from Commands
#commit, #kill, #logs, #pull, #resolve_image_name, #resolve_untagged_image_name, #tag, #wait
Constructor Details
Returns a new instance of Instance.
9
10
11
|
# File 'lib/henk/instance.rb', line 9
def initialize
@running_containers = []
end
|
Instance Method Details
#after_subshell(&block) ⇒ Object
Block is passed sheller result. Called regardless of error status
28
29
30
|
# File 'lib/henk/instance.rb', line 28
def after_subshell(&block)
@after_subshell_block = block
end
|
#before_subshell(&block) ⇒ Object
23
24
25
|
# File 'lib/henk/instance.rb', line 23
def before_subshell(&block)
@before_subshell_block = block
end
|
#execute(*arguments) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/henk/instance.rb', line 48
def execute(*arguments)
@before_subshell_block.call(Sheller.command(*arguments)) if @before_subshell_block
result = Sheller.execute(*arguments)
unless result.exit_status.success?
block = @subshell_error_block || Proc.new do |status|
raise "Subshell exited with status #{status}"
end
block.call(result.exit_status)
end
@after_subshell_block.call(result) if @after_subshell_block
result
end
|
#execute_for_lines(*arguments) ⇒ Object
70
71
72
73
|
# File 'lib/henk/instance.rb', line 70
def execute_for_lines(*arguments)
sheller_result = execute(*arguments)
sheller_result.stdout.chomp.split("\n") if sheller_result.exit_status.success?
end
|
#execute_for_word(*arguments) ⇒ Object
65
66
67
68
|
# File 'lib/henk/instance.rb', line 65
def execute_for_word(*arguments)
sheller_result = execute(*arguments)
sheller_result.stdout.chomp if sheller_result.exit_status.success?
end
|
#on_subshell_error(&block) ⇒ Object
Block is passed exit status object
18
19
20
|
# File 'lib/henk/instance.rb', line 18
def on_subshell_error(&block)
@subshell_error_block = block
end
|
#run_commit(*args) {|step| ... } ⇒ Object
32
33
34
35
36
37
|
# File 'lib/henk/instance.rb', line 32
def run_commit(*args)
step = Step.new(self, *args)
yield step if block_given?
step.perform!
step
end
|
#running_containers ⇒ Object
13
14
15
|
# File 'lib/henk/instance.rb', line 13
def running_containers
@running_containers.to_enum
end
|
#sequence(&block) ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/henk/instance.rb', line 39
def sequence(&block)
seq = Sequence.new(self)
if block.arity.zero?
seq.instance_eval(&block)
else
yield seq
end
end
|