Class: Checks
- Inherits:
-
Object
- Object
- Checks
- Includes:
- Singleton
- Defined in:
- lib/checks.rb,
lib/checks/version.rb
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Attribute Summary collapse
-
#config_path ⇒ Object
Returns the value of attribute config_path.
Class Method Summary collapse
Instance Method Summary collapse
- #checkin(*check) ⇒ Object
- #checkin!(*check) ⇒ Object
- #config ⇒ Object
-
#initialize ⇒ Checks
constructor
A new instance of Checks.
- #manual_checkin(path) ⇒ Object
- #reload! ⇒ Object
Constructor Details
#initialize ⇒ Checks
Returns a new instance of Checks.
17 18 19 |
# File 'lib/checks.rb', line 17 def initialize self.config_path = defined?(Rails) ? Rails.root.join('config/checks.yml').to_s : 'config/checks.yml' end |
Instance Attribute Details
#config_path ⇒ Object
Returns the value of attribute config_path.
9 10 11 |
# File 'lib/checks.rb', line 9 def config_path @config_path end |
Class Method Details
.checkin(*args) ⇒ Object
13 |
# File 'lib/checks.rb', line 13 def checkin(*args); instance.checkin(*args); end |
.checkin!(*args) ⇒ Object
14 |
# File 'lib/checks.rb', line 14 def checkin!(*args); instance.checkin!(*args); end |
.manual_checkin(*args) ⇒ Object
12 |
# File 'lib/checks.rb', line 12 def manual_checkin(*args); instance.manual_checkin(*args); end |
Instance Method Details
#checkin(*check) ⇒ Object
39 40 41 42 |
# File 'lib/checks.rb', line 39 def checkin(*check) path = path_for *check invoke "http://hchk.io/#{path}" if path end |
#checkin!(*check) ⇒ Object
44 45 46 47 48 |
# File 'lib/checks.rb', line 44 def checkin!(*check) path = path_for *check raise ArgumentError.new("unknown check #{check.join(".")}") unless path invoke "http://hchk.io/#{path}" end |
#config ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/checks.rb', line 26 def config @config ||= begin path = config_path.to_s return {} unless ::File.exist?(path) YAML.load_file(path).fetch('checks') end end |
#manual_checkin(path) ⇒ Object
50 51 52 |
# File 'lib/checks.rb', line 50 def manual_checkin(path) invoke "http://hchk.io/#{path}" end |
#reload! ⇒ Object
34 35 36 37 |
# File 'lib/checks.rb', line 34 def reload! @config = nil config end |