Class: Pantry::Exec::Command
- Inherits:
-
Command
- Object
- Command
- Pantry::Exec::Command
- Defined in:
- lib/pantry/exec/command.rb
Overview
Execute a Shell command, returning STDOUT, STDERR, and the status code. Executes as the user the Pantry Client is running under.
Instance Method Summary collapse
-
#initialize(*command_and_args) ⇒ Command
constructor
A new instance of Command.
- #perform(message) ⇒ Object
- #receive_client_response(response) ⇒ Object
- #to_message ⇒ Object
Constructor Details
#initialize(*command_and_args) ⇒ Command
Returns a new instance of Command.
13 14 15 |
# File 'lib/pantry/exec/command.rb', line 13 def initialize(*command_and_args) @command_and_args = command_and_args end |
Instance Method Details
#perform(message) ⇒ Object
23 24 25 26 27 |
# File 'lib/pantry/exec/command.rb', line 23 def perform() command_and_args = .body[0] stdout, stderr, status = Open3.capture3(*command_and_args) [stdout, stderr, status.to_i] end |
#receive_client_response(response) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/pantry/exec/command.rb', line 29 def receive_client_response(response) stdout, stderr, status = response.body Pantry.ui.say("From #{response.from}") Pantry.ui.say(stdout) Pantry.ui.say(stderr) end |
#to_message ⇒ Object
17 18 19 20 21 |
# File 'lib/pantry/exec/command.rb', line 17 def = super << @command_and_args end |