Module: Patriot::Command::ExitCode

Defined in:
lib/patriot/command.rb

Overview

exit code of a command

Constant Summary collapse

SUCCEEDED =

successfully finished

0
FAILED =

failed

1
SKIPPED =

skip (e.g., updated elsewhere)

-1

Class Method Summary collapse

Class Method Details

.name_of(exit_code) ⇒ String

Returns string expression of the exit code.

Parameters:

Returns:

  • (String)

    string expression of the exit code



48
49
50
51
52
53
54
55
# File 'lib/patriot/command.rb', line 48

def name_of(exit_code)
  exit_code = exit_code.to_i
  return case exit_code
    when SUCCEEDED  then "SUCCEEDED"
    when FAILED     then "FAILED"
    else exit_code.to_s # not nil for backward compatibility
  end
end

.value_of(code_name) ⇒ Fixnum

Returns exit code of the code name.

Parameters:

Returns:

  • (Fixnum)

    exit code of the code name



60
61
62
63
64
65
66
67
# File 'lib/patriot/command.rb', line 60

def value_of(code_name)
  return code_name if code_name.is_a?(Fixnum)
  return case code_name
  when /SUCCEEDED/i then SUCCEEDED
  when /FAILED/i    then FAILED
  else raise "unknown exit code name: #{code_name}"
  end
end