Class: Foreplay::Engine::Remote::Step

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Foreplay

#log, #terminate

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

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/foreplay/engine/remote/step.rb', line 6

def host
  @host
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



6
7
8
# File 'lib/foreplay/engine/remote/step.rb', line 6

def instructions
  @instructions
end

#shellObject (readonly)

Returns the value of attribute shell.



6
7
8
# File 'lib/foreplay/engine/remote/step.rb', line 6

def shell
  @shell
end

#stepObject (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

#executeObject



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

Returns:

  • (Boolean)


30
31
32
# File 'lib/foreplay/engine/remote/step.rb', line 30

def silent?
  @silent ||= instructions.key?('verbose') ? false : step['silent']
end