Sha256: 47aacc0d9e041507f3403ceecf002df54d02212143a811ec6838c079c28e74e3

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

module Scripted
  module Formatters
    module HumanStatus

      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

      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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scripted-0.0.1 lib/scripted/formatters/human_status.rb