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

INDENT, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Foreplay

#terminate

Constructor Details

#initialize(h, s, i) ⇒ Check

Returns a new instance of Check.



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

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

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



3
4
5
# File 'lib/foreplay/engine/remote/check.rb', line 3

def host
  @host
end

#instructionsObject (readonly)

Returns the value of attribute instructions.



3
4
5
# File 'lib/foreplay/engine/remote/check.rb', line 3

def instructions
  @instructions
end

#stepsObject (readonly)

Returns the value of attribute steps.



3
4
5
# File 'lib/foreplay/engine/remote/check.rb', line 3

def steps
  @steps
end

Instance Method Details

#list_commands(step) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/foreplay/engine/remote/check.rb', line 35

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

  commands.each do |command|
    puts "#{host}#{INDENT * 2}#{command}" unless step['silent']
  end
end

#list_file_contents(id) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/foreplay/engine/remote/check.rb', line 25

def list_file_contents(id)
  i = instructions[id]

  if i.is_a? Hash
    i.each { |k, v| puts "#{host}#{INDENT * 2}#{k}: #{v}" }
  else
    puts "#{host}#{INDENT * 2}#{i}"
  end
end

#performObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/foreplay/engine/remote/check.rb', line 11

def perform
  steps.each do |step|
    puts "#{host}#{INDENT}#{(step['commentary'] || step['command']).yellow}" unless step['silent'] == true

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

  ''
end