Class: Methadone::ExecutionStrategy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/methadone/execution_strategy/base.rb

Overview

Base for any ExecutionStrategy implementation. Currently, this is nothing more than an interface specification.

Direct Known Subclasses

JVM, MRI

Instance Method Summary collapse

Instance Method Details

#exception_meaning_command_not_foundObject

Returns the class that, if caught by calling #run_command, represents the underlying command not existing. For example, in MRI Ruby, if you try to execute a non-existent command, you get a Errno::ENOENT.


27
28
29
# File 'lib/methadone/execution_strategy/base.rb', line 27

def exception_meaning_command_not_found
  subclass_must_implement!
end

#run_command(command) ⇒ Object

Executes the command and returns the results back. This should do no logging or other logic other than to execute the command and return the required results. If command is an array, use exec directly bypassing any tokenization, shell or otherwise; otherwise use the normal shell interpretation of the command string.

command

the command-line to run, as an Array or a String

Returns an array of size 3:

[0]

The standard output of the command as a String, never nil

[1]

The standard error output of the command as a String, never nil

[2]

A Process::Status-like objects that responds to exitstatus which returns the exit code of the command (e.g. 0 for success).


20
21
22
# File 'lib/methadone/execution_strategy/base.rb', line 20

def run_command(command)
  subclass_must_implement!
end