Sha256: c19b8fe53f0236902955b5746ed5177f2a7f65529ffd57e058e8fd0427da83b8

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

module Outpost
  # Contain the status report of an Outpost execution. Holds the name,
  # description and status of the reported item.
  class Report
    # Summarizes the list of statuses in a single status only.
    # The logic is rather simple - it will return the lowest status
    # present in the list.
    #
    # Examples:
    #
    # if passed [:up, :up, :up], will result on :up
    #
    # if passed [:up, :down, :up], will result on :down
    #
    # @params [Array] status_list a list of statuses to be analyzed
    # @return [Symbol] the final status to be considered.
    def self.summarize(status_list)
      return :down if status_list.empty? || status_list.include?(:down)
      return :up
    end

    attr_reader :name, :description, :status

    def initialize(params)
      @name        = params[:name]
      @description = params[:description]
      @status      = params[:status]
    end

    def to_s
      "#{name}: '#{description}' is reporting #{status}."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-0.2.0 lib/outpost/report.rb