okcomputer 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -25,11 +25,19 @@ Or install it yourself as:
25
25
  To perform the default checks (application running and ActiveRecord database
26
26
  connection), do nothing other than adding to your application's Gemfile.
27
27
 
28
- If you use a database adapter other than ActiveRecord, see Registering Custom
29
- Checks below to build your own database check and register it with the name
30
- "database" to replace the built-in check, or use
31
- `OKComputer::Registry.deregister "database"` to stop checking your database
32
- altogether.
28
+ ### If Not Using ActiveRecord
29
+
30
+ We also include a MongoidCheck, but do not register it. If you use Mongoid,
31
+ replace the default ActiveRecord check like so:
32
+
33
+ ```ruby
34
+ OKComputer::Registry.register "database", OKComputer::MongoidCheck.new
35
+ ```
36
+
37
+ If you use another database adapter, see Registering Custom Checks below to
38
+ build your own database check and register it with the name "database" to
39
+ replace the built-in check, or use `OKComputer::Registry.deregister "database"`
40
+ to stop checking your database altogether.
33
41
 
34
42
  ### Registering Additional Checks
35
43
 
data/lib/okcomputer.rb CHANGED
@@ -4,8 +4,9 @@ require "okcomputer/check_collection"
4
4
  require "okcomputer/registry"
5
5
 
6
6
  # and the built-in checks
7
+ require "okcomputer/built_in_checks/active_record_check"
7
8
  require "okcomputer/built_in_checks/default_check"
8
- require "okcomputer/built_in_checks/database_check"
9
+ require "okcomputer/built_in_checks/mongoid_check"
9
10
  require "okcomputer/built_in_checks/resque_backed_up_check"
10
11
  require "okcomputer/built_in_checks/resque_down_check"
11
12
 
@@ -13,5 +14,5 @@ module OKComputer
13
14
  end
14
15
 
15
16
  OKComputer::Registry.register "default", OKComputer::DefaultCheck.new
16
- OKComputer::Registry.register "database", OKComputer::DatabaseCheck.new
17
+ OKComputer::Registry.register "database", OKComputer::ActiveRecordCheck.new
17
18
 
@@ -1,5 +1,5 @@
1
1
  module OKComputer
2
- class DatabaseCheck < Check
2
+ class ActiveRecordCheck < Check
3
3
  # Public: Return the schema version of the database
4
4
  def call
5
5
  "Schema version: #{schema_version}"
@@ -0,0 +1,30 @@
1
+ module OKComputer
2
+ class MongoidCheck < Check
3
+ # Public: Return the status of the mongodb
4
+ def call
5
+ "Successfully connected to mongodb #{mongodb_name}"
6
+ rescue ConnectionFailed => e
7
+ mark_failure
8
+ "Failed to connect: '#{e}'"
9
+ end
10
+
11
+ # Public: The stats for the app's mongodb
12
+ #
13
+ # Returns a hash with the status of the db
14
+ def mongodb_stats
15
+ Mongoid.database.stats
16
+ rescue => e
17
+ raise ConnectionFailed, e
18
+ end
19
+
20
+ # Public: The name of the app's mongodb
21
+ #
22
+ # Returns a string with the mongdb name
23
+ def mongodb_name
24
+ mongodb_stats["db"]
25
+ end
26
+
27
+ ConnectionFailed = Class.new(StandardError)
28
+ end
29
+ end
30
+
@@ -1,3 +1,3 @@
1
1
  module OKComputer
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,64 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okcomputer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
4
  prerelease:
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Patrick Byrne
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-07 00:00:00.000000000 Z
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
15
+ version_requirements: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
20
  none: false
21
+ prerelease: false
22
+ name: rails
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - ~>
28
26
  - !ruby/object:Gem::Version
29
27
  version: '3.0'
30
- - !ruby/object:Gem::Dependency
31
- name: sqlite3
32
- requirement: !ruby/object:Gem::Requirement
33
28
  none: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
34
32
  requirements:
35
33
  - - ! '>='
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
36
  none: false
37
+ prerelease: false
38
+ name: sqlite3
39
+ requirement: !ruby/object:Gem::Requirement
42
40
  requirements:
43
41
  - - ! '>='
44
42
  - !ruby/object:Gem::Version
45
43
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rspec-rails
48
- requirement: !ruby/object:Gem::Requirement
49
44
  none: false
45
+ type: :development
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
50
48
  requirements:
51
49
  - - ! '>='
52
50
  - !ruby/object:Gem::Version
53
51
  version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
52
  none: false
53
+ prerelease: false
54
+ name: rspec-rails
55
+ requirement: !ruby/object:Gem::Requirement
58
56
  requirements:
59
57
  - - ! '>='
60
58
  - !ruby/object:Gem::Version
61
59
  version: '0'
60
+ none: false
61
+ type: :development
62
62
  description: ! "\n Inspired by the simplicity of Fitter Happier, but frustrated
63
63
  by its lack of\n flexibility, we built OK Computer. Create and register your
64
64
  own custom\n health checks, or choose from the built-in library of checks to
@@ -71,8 +71,9 @@ extra_rdoc_files: []
71
71
  files:
72
72
  - app/controllers/ok_computer_controller.rb
73
73
  - config/routes.rb
74
- - lib/okcomputer/built_in_checks/database_check.rb
74
+ - lib/okcomputer/built_in_checks/active_record_check.rb
75
75
  - lib/okcomputer/built_in_checks/default_check.rb
76
+ - lib/okcomputer/built_in_checks/mongoid_check.rb
76
77
  - lib/okcomputer/built_in_checks/resque_backed_up_check.rb
77
78
  - lib/okcomputer/built_in_checks/resque_down_check.rb
78
79
  - lib/okcomputer/check.rb
@@ -92,23 +93,23 @@ rdoc_options: []
92
93
  require_paths:
93
94
  - lib
94
95
  required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
96
  requirements:
97
97
  - - ! '>='
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: -3398696995486487009
103
- required_rubygems_version: !ruby/object:Gem::Requirement
102
+ hash: -847942118796970126
104
103
  none: false
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ! '>='
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: -3398696995486487009
111
+ hash: -847942118796970126
112
+ none: false
112
113
  requirements: []
113
114
  rubyforge_project:
114
115
  rubygems_version: 1.8.24