Class: Fission::Action::ShellExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/fission/action/shell_executor.rb

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ ShellExecutor

Internal: Create a new ShellExecutor object.

cmd - Command to execute as a String

Examples:

Fission::Action::ShellExecutor.new 'ls /var/log'

Returns a new Fission::Action::ShellExecutor object.



15
16
17
# File 'lib/fission/action/shell_executor.rb', line 15

def initialize(cmd)
  @cmd = cmd
end

Instance Method Details

#executeObject

Internal: Executes the command in the shell. The command will be executed using the ruby ‘`’ method.

Examples:

@executor.execute

Returns a Hash with two keys. The key ‘output’ will contain the output from the command. The key ‘process_status’ will conatian a standard ruby Process::Status object.



30
31
32
# File 'lib/fission/action/shell_executor.rb', line 30

def execute
  { 'output' => `#{@cmd}`, 'process_status' => $? }
end