Class: KubernetesHarness::ShellCommand
- Inherits:
-
Object
- Object
- KubernetesHarness::ShellCommand
- Defined in:
- lib/k8s_harness/shell_command.rb
Overview
Handles all interactions with shells
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#all_eof(files) ⇒ Object
Courtesy of: gist.github.com/chrisn/7450808.
- #execute! ⇒ Object
-
#initialize(command, environment: {}) ⇒ ShellCommand
constructor
Ruby 2.7 deprecated keyword arguments in favor of passing in Hashes.
- #success?(exit_code: 0) ⇒ Boolean
Constructor Details
#initialize(command, environment: {}) ⇒ ShellCommand
Ruby 2.7 deprecated keyword arguments in favor of passing in Hashes. TODO: Refactor to account for this.
13 14 15 16 17 18 19 20 |
# File 'lib/k8s_harness/shell_command.rb', line 13 def initialize(command, environment: {}) KubernetesHarness.logger.debug("Creating new command #{command} with env #{environment}") @command = command @environment = environment @exitcode = nil @stdout = nil @stderr = nil end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
9 10 11 |
# File 'lib/k8s_harness/shell_command.rb', line 9 def command @command end |
#stderr ⇒ Object
Returns the value of attribute stderr.
9 10 11 |
# File 'lib/k8s_harness/shell_command.rb', line 9 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
9 10 11 |
# File 'lib/k8s_harness/shell_command.rb', line 9 def stdout @stdout end |
Instance Method Details
#all_eof(files) ⇒ Object
Courtesy of: gist.github.com/chrisn/7450808
36 37 38 |
# File 'lib/k8s_harness/shell_command.rb', line 36 def all_eof(files) files.find { |f| !f.eof }.nil? end |
#execute! ⇒ Object
22 23 24 25 26 |
# File 'lib/k8s_harness/shell_command.rb', line 22 def execute! @stdout, @stderr, @exitcode = read_output_in_chunks(@environment) show_debug_command_output end |
#success?(exit_code: 0) ⇒ Boolean
28 29 30 |
# File 'lib/k8s_harness/shell_command.rb', line 28 def success?(exit_code: 0) @exitcode == exit_code end |