Class: ChatopsDeployer::Command
- Inherits:
-
Object
- Object
- ChatopsDeployer::Command
- Defined in:
- lib/chatops_deployer/command.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Command
constructor
A new instance of Command.
- #run(command, logger) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
12 13 14 15 |
# File 'lib/chatops_deployer/command.rb', line 12 def initialize @output = "" @status = nil end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
6 7 8 |
# File 'lib/chatops_deployer/command.rb', line 6 def output @output end |
Class Method Details
.run(command: "", logger: ::Logger.new(STDOUT)) ⇒ Object
8 9 10 |
# File 'lib/chatops_deployer/command.rb', line 8 def self.run(command: "", logger: ::Logger.new(STDOUT)) new.run(command, logger) end |
Instance Method Details
#run(command, logger) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chatops_deployer/command.rb', line 17 def run(command, logger) logger.info "Running command: #{command.inspect}" Open3.popen2e(*(Array(command))) do |_, out_err, thread| out_err.each_line do |line| logger.info line @output << line end @status = thread.value end self end |
#success? ⇒ Boolean
29 30 31 |
# File 'lib/chatops_deployer/command.rb', line 29 def success? @status && @status.success? end |