Sha256: 28781e97d8715e3dbb309b63eeb1c2ccb35b85ceed4ca6ce892bb59a31047e0b

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Diagnostics
  module Methods

    DIAGNOSTIC_MESSAGES = {
      :passed  => 'All Systems Operational',
      :warning => 'Experiencing Issues',
      :failed  => 'System Failure',
      :none    => 'No Diagnostic Checks Run'
    }

    def diagnostic_checks
      Diagnostics.checks
    end

    def diagnostic_check(name)
      Check.find(name)
    end

    def diagnostic_message
      case diagnostic_status
        when :passed  then DIAGNOSTIC_MESSAGES[:passed]
        when :warning then DIAGNOSTIC_MESSAGES[:warning]
        when :failed  then DIAGNOSTIC_MESSAGES[:failed]
        when :none    then DIAGNOSTIC_MESSAGES[:none]
      end
    end

    def diagnostic_status
      return :failed  if diagnostic_statuses.include?(:failed)
      return :warning if diagnostic_statuses.include?(:warning)
      return :passed  if diagnostic_statuses.include?(:passed)
      :none
    end

  private

    def diagnostic_statuses
      @diagnostic_statuses ||= diagnostic_checks.map(&:status).uniq
    end

  end
end

class Object
  include Diagnostics::Methods
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
diagnostics-0.0.4 lib/diagnostics/methods.rb
diagnostics-0.0.3 lib/diagnostics/methods.rb