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
DEFAULT_PORT, PORT_GAP, VERSION
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
- #execute ⇒ Object
- #execute_command(command) ⇒ Object
-
#initialize(h, sh, st, i) ⇒ Step
constructor
A new instance of Step.
- #output(o) ⇒ Object
- #silent? ⇒ Boolean
Methods included from Foreplay
Constructor Details
#initialize(h, sh, st, i) ⇒ Step
Returns a new instance of Step.
8 9 10 11 12 13 |
# File 'lib/foreplay/engine/remote/step.rb', line 8 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.
6 7 8 |
# File 'lib/foreplay/engine/remote/step.rb', line 6 def host @host end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
6 7 8 |
# File 'lib/foreplay/engine/remote/step.rb', line 6 def instructions @instructions end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
6 7 8 |
# File 'lib/foreplay/engine/remote/step.rb', line 6 def shell @shell end |
#step ⇒ Object (readonly)
Returns the value of attribute step.
6 7 8 |
# File 'lib/foreplay/engine/remote/step.rb', line 6 def step @step end |
Instance Method Details
#execute ⇒ Object
15 16 17 18 19 |
# File 'lib/foreplay/engine/remote/step.rb', line 15 def execute s = Foreplay::Engine::Step.new(host, step, instructions) s.announce output s.commands.map { |command| execute_command(command) }.join end |
#execute_command(command) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/foreplay/engine/remote/step.rb', line 21 def execute_command(command) o = '' process = shell.execute command process.on_output { |_, po| o += po } shell.wait! terminate(o) unless step['ignore_error'] == true || process.exit_status == 0 o end |
#output(o) ⇒ Object
34 35 36 37 |
# File 'lib/foreplay/engine/remote/step.rb', line 34 def output(o) log o, host: host, silent: silent?, indent: 1 o end |
#silent? ⇒ Boolean
30 31 32 |
# File 'lib/foreplay/engine/remote/step.rb', line 30 def silent? @silent ||= instructions.key?('verbose') ? false : step['silent'] end |