Class: Henk::Instance
Instance Method Summary collapse
-
#after_subshell(&block) ⇒ Object
Block is passed sheller result.
-
#before_subshell(&block) ⇒ Object
Block is passed script.
- #execute(*arguments) ⇒ Object
- #execute_for_word(*arguments) ⇒ Object
-
#on_subshell_error(&block) ⇒ Object
Block is passed exit status object.
- #run_commit(*args) {|step| ... } ⇒ Object
- #sequence(&block) ⇒ Object
Methods included from Commands
#commit, #logs, #pull, #resolve_image_name, #wait
Instance Method Details
#after_subshell(&block) ⇒ Object
Block is passed sheller result. Called regardless of error status
20 21 22 |
# File 'lib/henk/instance.rb', line 20 def after_subshell(&block) @after_subshell_block = block end |
#before_subshell(&block) ⇒ Object
Block is passed script
15 16 17 |
# File 'lib/henk/instance.rb', line 15 def before_subshell(&block) @before_subshell_block = block end |
#execute(*arguments) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/henk/instance.rb', line 40 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_word(*arguments) ⇒ Object
57 58 59 60 |
# File 'lib/henk/instance.rb', line 57 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
10 11 12 |
# File 'lib/henk/instance.rb', line 10 def on_subshell_error(&block) @subshell_error_block = block end |
#run_commit(*args) {|step| ... } ⇒ Object
24 25 26 27 28 29 |
# File 'lib/henk/instance.rb', line 24 def run_commit(*args) step = Step.new(self, *args) yield step if block_given? step.perform! step end |
#sequence(&block) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/henk/instance.rb', line 31 def sequence(&block) seq = Sequence.new(self) if block.arity.zero? seq.instance_eval(&block) else yield seq end end |