Module: Scripted::Formatters::HumanStatus

Included in:
Stats, Table, Websocket
Defined in:
lib/scripted/formatters/human_status.rb

Instance Method Summary collapse

Instance Method Details

#human_status(command) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/scripted/formatters/human_status.rb', line 5

def human_status(command)
  translations = {
    :running                                  => "running",
    :success_ran_because_other_command_failed => "success, ran because other command failed",
    :failed_ran_because_other_command_failed  => "failed, ran because other command failed",
    :skipped_because_no_other_command_failed  => "skipped, because no other command failed",
    :failed_but_ignored                       => "failed, but ignored",
    :success                                  => "success",
    :failed_and_halted                        => "failed and halted",
    :failed                                   => "failed",
    :not_executed                             => "didn't run",
    :unknown                                  => "unknown"
  }
  translations[status_code(command)]
end

#status_code(command) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/scripted/formatters/human_status.rb', line 21

def status_code(command)
  case
  when command.running?                                then :running
  when command.only_when_failed? && command.success?   then :success_ran_because_other_command_failed
  when command.only_when_failed? && command.failed?    then :failed_ran_because_other_command_failed
  when command.only_when_failed? && !command.executed? then :skipped_because_no_other_command_failed
  when command.failed_but_unimportant?                 then :failed_but_ignored
  when command.success?                                then :success
  when command.halted?                                 then :failed_and_halted
  when command.failed?                                 then :failed
  when !command.executed?                              then :not_executed
  else :unknown
  end
end