Class: Jets::Shim::Adapter::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/shim/adapter/command.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #event, #target

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Util::Logging

#log

Constructor Details

This class inherits a constructor from Jets::Shim::Adapter::Base

Instance Method Details

#handleObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jets/shim/adapter/command.rb', line 5

def handle
  cmd = event[:command]
  result = {stdout: "", stderr: ""}
  # splat works for both String and Array
  Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thread|
    result[:stdout] << stdout.read
    result[:stderr] << stderr.read
    result[:status] = wait_thread.value.exitstatus
  end
  result
end

#handle?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/jets/shim/adapter/command.rb', line 17

def handle?
  event[:command]
end