class Pantry::Exec::Command

Execute a Shell command, returning STDOUT, STDERR, and the status code. Executes as the user the Pantry Client is running under.

Public Class Methods

new(*command_and_args) click to toggle source
# File lib/pantry/exec/command.rb, line 13
def initialize(*command_and_args)
  @command_and_args = command_and_args
end

Public Instance Methods

perform(message) click to toggle source
# File lib/pantry/exec/command.rb, line 23
def perform(message)
  command_and_args       = message.body[0]
  stdout, stderr, status = Open3.capture3(*command_and_args)
  [stdout, stderr, status.to_i]
end
receive_client_response(response) click to toggle source
# 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() click to toggle source
Calls superclass method
# File lib/pantry/exec/command.rb, line 17
def to_message
  message = super
  message << @command_and_args
  message
end