Module: Easymon
- Defined in:
- lib/easymon.rb,
lib/easymon/engine.rb,
lib/easymon/result.rb,
lib/easymon/testing.rb,
lib/easymon/version.rb,
lib/easymon/checklist.rb,
lib/easymon/repository.rb,
lib/easymon/checks/http_check.rb,
lib/easymon/checks/redis_check.rb,
lib/easymon/checks/memcached_check.rb,
lib/easymon/checks/semaphore_check.rb,
lib/easymon/checks/active_record_check.rb,
lib/easymon/checks/redis_writeable_check.rb,
lib/easymon/checks/traffic_enabled_check.rb,
app/controllers/easymon/checks_controller.rb,
lib/easymon/checks/multi_active_record_check.rb,
lib/easymon/checks/split_active_record_check.rb,
app/controllers/easymon/application_controller.rb,
lib/easymon/checks/active_record_mysql_writeable_check.rb
Defined Under Namespace
Modules: Testing
Classes: ActiveRecordCheck, ActiveRecordMysqlWriteableCheck, ApplicationController, Checklist, ChecksController, Engine, HttpCheck, MemcachedCheck, MultiActiveRecordCheck, RedisCheck, RedisWriteableCheck, Repository, Result, SemaphoreCheck, SplitActiveRecordCheck, TrafficEnabledCheck
Constant Summary
collapse
- NoSuchCheck =
Class.new(StandardError)
- VERSION =
"1.6.4"
Class Method Summary
collapse
Class Method Details
.authorize_with=(block) ⇒ Object
86
87
88
|
# File 'lib/easymon.rb', line 86
def self.authorize_with=(block)
@authorize_with = block
end
|
.authorized?(request) ⇒ Boolean
90
91
92
|
# File 'lib/easymon.rb', line 90
def self.authorized?(request)
@authorize_with.nil? ? true : @authorize_with.call(request)
end
|
.has_before_action? ⇒ Boolean
50
51
52
|
# File 'lib/easymon.rb', line 50
def self.has_before_action?
Easymon.rails_newer_than?("4.0.0.beta")
end
|
.has_render_plain? ⇒ Boolean
45
46
47
48
|
# File 'lib/easymon.rb', line 45
def self.has_render_plain?
Easymon.rails_newer_than?("4.1.0.beta")
end
|
.mountable_engine? ⇒ Boolean
37
38
39
|
# File 'lib/easymon.rb', line 37
def self.mountable_engine?
Easymon.rails_version > Gem::Version.new("3.1")
end
|
.rails2? ⇒ Boolean
29
30
31
|
# File 'lib/easymon.rb', line 29
def self.rails2?
Easymon.rails_version.between?(Gem::Version.new("2.3"), Gem::Version.new("3.0"))
end
|
.rails30? ⇒ Boolean
33
34
35
|
# File 'lib/easymon.rb', line 33
def self.rails30?
Easymon.rails_version.between?(Gem::Version.new("3.0"), Gem::Version.new("3.1"))
end
|
.rails_newer_than?(version) ⇒ Boolean
41
42
43
|
# File 'lib/easymon.rb', line 41
def self.rails_newer_than?(version)
Easymon.rails_version > Gem::Version.new(version)
end
|
.rails_version ⇒ Object
25
26
27
|
# File 'lib/easymon.rb', line 25
def self.rails_version
Gem::Version.new(Rails.version)
end
|
.routes(mapper, path = "/up") ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/easymon.rb', line 54
def self.routes(mapper, path = "/up")
if Easymon.rails2?
$:.unshift File.expand_path(File.join(
File.dirname(__FILE__),
"..", "app", "controllers"))
require "easymon/checks_controller"
mapper.instance_eval do
connect "#{path}.:format", controller: "easymon/checks", action: "index"
connect "#{path}/:check.:format", controller: "easymon/checks", action: "show"
end
elsif Easymon.rails30?
mapper.instance_eval do
get "#{path}(.:format)", controller: "easymon/checks", action: "index"
get "#{path}/:check", controller: "easymon/checks", action: "show"
end
elsif Easymon.mountable_engine?
mapper.instance_eval do
get "/(.:format)", to: "checks#index"
root to: "checks#index"
get "/:check", to: "checks#show"
end
end
end
|
.timing_to_ms(timing = 0) ⇒ Object
82
83
84
|
# File 'lib/easymon.rb', line 82
def self.timing_to_ms(timing = 0)
sprintf("%.3f", (timing * 1000))
end
|