Module: Pingable

Defined in:
lib/pingable/core.rb,
lib/pingable/handler.rb,
lib/pingable/version.rb,
lib/pingable/common_checks.rb

Defined Under Namespace

Classes: Handler

Constant Summary collapse

VERSION =
'0.0.5'

Class Method Summary collapse

Class Method Details

.add_check(check) ⇒ Object



6
7
8
# File 'lib/pingable/core.rb', line 6

def add_check(check)
  @@checks << check
end

.common_checks!Object

Add checks for standard gems such as Active Record.



7
8
9
10
11
12
13
# File 'lib/pingable/common_checks.rb', line 7

def common_checks!
  unless @@common_checks_added
    add_active_record!
    add_rails_cache!
    @@common_checks_added = true
  end
end

.run_checks!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pingable/core.rb', line 10

def run_checks!
  failures = []
  @@checks.each do |check|
    begin
      result = check.call
    rescue Exception => e
      failures.push(:message => "Pinger check failed: #{e}")
    else
      if result
        case result
          when Array
            failures.concat result
          when String
            failures.push(:message => result)
          else
            failures.push(result)
        end
      end
    end
  end
  failures
end