Class: Outpost::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/outpost/report.rb

Overview

Contain the status report of an Outpost execution. Holds the name, description and status of the reported item.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Report


25
26
27
28
29
30
# File 'lib/outpost/report.rb', line 25

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data


23
24
25
# File 'lib/outpost/report.rb', line 23

def data
  @data
end

#descriptionObject (readonly)

Returns the value of attribute description


23
24
25
# File 'lib/outpost/report.rb', line 23

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name


23
24
25
# File 'lib/outpost/report.rb', line 23

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status


23
24
25
# File 'lib/outpost/report.rb', line 23

def status
  @status
end

Class Method Details

.summarize(status_list) ⇒ Symbol

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


17
18
19
20
21
# File 'lib/outpost/report.rb', line 17

def self.summarize(status_list)
  return :down if status_list.empty? || status_list.include?(:down)
  return :warning if status_list.include?(:warning)
  return :up
end

Instance Method Details

#to_sObject


32
33
34
# File 'lib/outpost/report.rb', line 32

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