Class: Bcome::Command
Instance Attribute Summary collapse
-
#bootstrap ⇒ Object
Wraps a command.
-
#command ⇒ Object
readonly
Wraps a command.
-
#exit_code ⇒ Object
Wraps a command.
-
#exit_signal(data) ⇒ Object
readonly
Wraps a command.
-
#instance ⇒ Object
readonly
Wraps a command.
-
#stderr ⇒ Object
Wraps a command.
-
#stdout ⇒ Object
Wraps a command.
-
#success_exit_codes ⇒ Object
readonly
Wraps a command.
Instance Method Summary collapse
-
#initialize(params) ⇒ Command
constructor
A new instance of Command.
- #is_success? ⇒ Boolean
- #output ⇒ Object
- #pretty_result ⇒ Object
- #proxy ⇒ Object
- #ssh_keys ⇒ Object
- #ssh_user ⇒ Object
Constructor Details
#initialize(params) ⇒ Command
Returns a new instance of Command.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/command.rb', line 7 def initialize(params) @command = params[:command] @instance = params[:instance] @bootstrap = params[:bootstrap] # whether to run this in bootstrap mode or not @success_exit_codes = params[:success_exit_codes] @stdout = "" @stderr = "" @exit_code = nil @exit_signal = nil end |
Instance Attribute Details
#bootstrap ⇒ Object
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def bootstrap @bootstrap end |
#command ⇒ Object (readonly)
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def command @command end |
#exit_code ⇒ Object
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def exit_code @exit_code end |
#exit_signal(data) ⇒ Object (readonly)
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def exit_signal @exit_signal end |
#instance ⇒ Object (readonly)
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def instance @instance end |
#stderr ⇒ Object
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def stderr @stderr end |
#stdout ⇒ Object
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def stdout @stdout end |
#success_exit_codes ⇒ Object (readonly)
Wraps a command. Convenient flex-point for logging etc
5 6 7 |
# File 'lib/command.rb', line 5 def success_exit_codes @success_exit_codes end |
Instance Method Details
#is_success? ⇒ Boolean
44 45 46 |
# File 'lib/command.rb', line 44 def is_success? success_exit_codes.include?(exit_code.to_s) end |
#output ⇒ Object
39 40 41 42 |
# File 'lib/command.rb', line 39 def output command_output = is_success? ? @stdout : "Exit code: #{@exit_code}\n\nSTDERR: #{@stderr}" return "\n#{command_output}" end |
#pretty_result ⇒ Object
19 20 21 |
# File 'lib/command.rb', line 19 def pretty_result return is_success? ? "success".success : "failure".failure end |
#proxy ⇒ Object
35 36 37 |
# File 'lib/command.rb', line 35 def proxy @bootstrap ? instance.proxy(true) : instance.proxy end |
#ssh_keys ⇒ Object
31 32 33 |
# File 'lib/command.rb', line 31 def ssh_keys @bootstrap ? [instance.bootstrap_settings[:key]] : instance.keys end |
#ssh_user ⇒ Object
23 24 25 |
# File 'lib/command.rb', line 23 def ssh_user @bootstrap ? instance.bootstrap_settings[:ssh_user] : instance.ssh_user end |