Class: Foreplay::Engine::Remote::Step
- Inherits:
-
Object
- Object
- Foreplay::Engine::Remote::Step
- Includes:
- Foreplay
- Defined in:
- lib/foreplay/engine/remote/step.rb
Constant Summary
Constants included from Foreplay
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
-
#step ⇒ Object
readonly
Returns the value of attribute step.
Instance Method Summary collapse
- #deploy ⇒ Object
-
#initialize(h, sh, st, i) ⇒ Step
constructor
A new instance of Step.
Methods included from Foreplay
Constructor Details
#initialize(h, sh, st, i) ⇒ Step
Returns a new instance of Step.
5 6 7 8 9 10 |
# File 'lib/foreplay/engine/remote/step.rb', line 5 def initialize(h, sh, st, i) @host = h @shell = sh @step = st @instructions = i end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/foreplay/engine/remote/step.rb', line 3 def host @host end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
3 4 5 |
# File 'lib/foreplay/engine/remote/step.rb', line 3 def instructions @instructions end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
3 4 5 |
# File 'lib/foreplay/engine/remote/step.rb', line 3 def shell @shell end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
3 4 5 |
# File 'lib/foreplay/engine/remote/step.rb', line 3 def step @step end |
Instance Method Details
#deploy ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/foreplay/engine/remote/step.rb', line 12 def deploy puts "#{host}#{INDENT}#{(step['commentary'] || step['command']).yellow}" unless step['silent'] == true # Output from this step output = '' previous = '' # We don't need or want the final CRLF commands = Foreplay::Engine::Step.new(step, instructions).build commands.each do |command| process = shell.execute command process.on_output do |_, o| previous = o output += previous end shell.wait! if step['ignore_error'] == true || process.exit_status == 0 print output.gsub!(/^/, "#{host}#{INDENT * 2}") unless step['silent'] == true || output.blank? else terminate(output) end end output end |