Class: Departure::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/departure/command.rb

Overview

Executes the given command returning it’s status and errors

Constant Summary collapse

COMMAND_NOT_FOUND =
127

Instance Method Summary collapse

Constructor Details

#initialize(command_line, error_log_path, logger) ⇒ Command

Constructor

Parameters:

  • command_line (String)
  • error_log_path (String)
  • logger (#write_no_newline)


11
12
13
14
15
# File 'lib/departure/command.rb', line 11

def initialize(command_line, error_log_path, logger)
  @command_line = command_line
  @error_log_path = error_log_path
  @logger = logger
end

Instance Method Details

#runProcess::Status

Executes the command returning its status. It also prints its stdout to the logger and its stderr to the file specified in error_log_path.

Returns:

  • (Process::Status)

Raises:



25
26
27
28
29
30
31
32
33
34
# File 'lib/departure/command.rb', line 25

def run
  log_started

  run_in_process

  log_finished

  validate_status!
  status
end