Class: Bcome::Ssh::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/objects/ssh/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Command

Returns a new instance of Command.



5
6
7
8
9
10
11
# File 'lib/objects/ssh/command.rb', line 5

def initialize(params)
  @raw = params[:raw]
  @node = params[:node]
  @exit_code = nil
  @exit_signal = nil
  @stdin = ''; @stdout = ''; @stderr = ''
end

Instance Attribute Details

#bootstrapObject

Returns the value of attribute bootstrap.



3
4
5
# File 'lib/objects/ssh/command.rb', line 3

def bootstrap
  @bootstrap
end

#exit_codeObject

Returns the value of attribute exit_code.



3
4
5
# File 'lib/objects/ssh/command.rb', line 3

def exit_code
  @exit_code
end

#nodeObject (readonly)

Returns the value of attribute node.



3
4
5
# File 'lib/objects/ssh/command.rb', line 3

def node
  @node
end

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/objects/ssh/command.rb', line 3

def raw
  @raw
end

#stderrObject

Returns the value of attribute stderr.



3
4
5
# File 'lib/objects/ssh/command.rb', line 3

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout.



3
4
5
# File 'lib/objects/ssh/command.rb', line 3

def stdout
  @stdout
end

Instance Method Details

#exit_signal(data) ⇒ Object



42
43
44
# File 'lib/objects/ssh/command.rb', line 42

def exit_signal(data)
  @exit_signal = data
end

#is_success?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/objects/ssh/command.rb', line 28

def is_success?
  exit_code.to_i == 0
end

#outputObject



23
24
25
26
# File 'lib/objects/ssh/command.rb', line 23

def output
  command_output = is_success? ? @stdout : "Exit code: #{@exit_code}\n\nSTDERR: #{@stderr}"
  "\n#{command_output}"
end

#pretty_resultObject



17
18
19
# File 'lib/objects/ssh/command.rb', line 17

def pretty_result
  is_success? ? 'success'.success : 'failure'.error
end

#success_codesObject



32
33
34
# File 'lib/objects/ssh/command.rb', line 32

def success_codes
  ['0']
end

#unset_nodeObject



13
14
15
# File 'lib/objects/ssh/command.rb', line 13

def unset_node
  @node = nil
end