]> CyberLeo.Net >> Repos - CDN/status.git/blob - lib/checks.rb
And behold, thus she sprang, fully formed, from the head of her progenitor.
[CDN/status.git] / lib / checks.rb
1 require 'configuration'
2 require 'check'
3 require 'database_check'
4 require 'website_check'
5
6
7 class Checks
8   @@config = "checks.yml"
9
10   def self.config
11     Configuration.load(@@config)
12   end
13
14   def initialize
15     @checks = []
16   end
17
18   def reload_config
19     return unless !@config || @config.stale?
20     @config ||= self.class.config
21     @checks = @config.map do |check|
22       Kernel.const_get(check[:class]).new(check)
23     end
24   end
25
26   def check
27     reload_config
28     @checks.each(&:do_it)
29   end
30
31   def passed?
32     @checks.map(&:passed?).uniq == [ true ]
33   end
34
35   def results
36     @checks
37   end
38 end