Class: Foreplay::Engine::Remote::Check

Inherits:
Object
  • Object
show all
Includes:
Foreplay
Defined in:
lib/foreplay/engine/remote/check.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, s, i) ⇒ Check

Returns a new instance of Check.



8
9
10
11
12
# File 'lib/foreplay/engine/remote/check.rb', line 8

def initialize(h, s, i)
  @host = h
  @steps = s
  @instructions = i
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



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

def instructions
  @instructions
end

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

Instance Method Details

#list_commands(step) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/foreplay/engine/remote/check.rb', line 38

def list_commands(step)
  commands = Foreplay::Engine::Step.new(host, step, instructions).commands

  commands.each do |command|
    log command, host: host, silent: step['silent']
  end
end

#list_file_contents(id) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/foreplay/engine/remote/check.rb', line 28

def list_file_contents(id)
  i = instructions[id]

  if i.is_a? Hash
    i.each { |k, v| log "#{k}: #{v}", host: host, indent: 1 }
  else
    log i, host: host, indent: 1
  end
end

#performObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/foreplay/engine/remote/check.rb', line 14

def perform
  steps.each do |step|
    log "#{(step['commentary'] || step['command']).yellow}", host: host, silent: step['silent']

    if step.key? 'key'
      list_file_contents step['key']
    else
      list_commands step
    end
  end

  ''
end