Module: Uptimr
- Defined in:
- lib/uptimr.rb,
lib/uptimr/util.rb,
lib/uptimr/check.rb,
lib/uptimr/error.rb,
lib/uptimr/version.rb
Defined Under Namespace
Classes: Check, UptimrError, Util
Constant Summary
collapse
- VERSION =
'0.1.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.base_url ⇒ Object
Returns the value of attribute base_url.
13
14
15
|
# File 'lib/uptimr.rb', line 13
def base_url
@base_url
end
|
Class Method Details
.config {|_self| ... } ⇒ Object
16
17
18
|
# File 'lib/uptimr.rb', line 16
def self.config
yield self
end
|
.handle_error(error) ⇒ Object
40
41
42
|
# File 'lib/uptimr.rb', line 40
def self.handle_error(error)
raise Uptimr::UptimrError.new(error)
end
|
.parse(raw_json) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/uptimr.rb', line 32
def self.parse(raw_json)
begin
Util.keys_to_sym MultiJson.load(raw_json)
rescue MultiJson::DecodeError => e
handle_error("JSON is buggered")
end
end
|
.request(path, options = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/uptimr.rb', line 20
def self.request(path, options={})
handle_error "You have not set your API url" if base_url.nil?
handle_error "Invalid HTTP method" unless %w(get post).include? options[:method].to_s
options.merge! url: "#{base_url}#{path}"
puts "About to request: #{options[:url]}"
response = generate_request(options)
parse response.body
end
|