rack-active_record_status 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ Gemfile.lock
data/README.rdoc CHANGED
@@ -29,9 +29,18 @@ Test your ActiveRecord connection by hitting
29
29
 
30
30
  Anything other than a 200 OK HTTP response code is an error.
31
31
 
32
- You may change which path the app middleware uses by passing an argument:
32
+ == Configuration
33
33
 
34
- config.middleware.use Rack::ActiveRecordStatus, '/custom_path'
34
+ Use the `:path` option to configure what patht eh middleware responds to.
35
+ Use the `:response` option to change the default response.
36
+
37
+ config.middleware.use Rack::ActiveRecordStatus, :path => '/custom_path' # Respond on /custom_path
38
+ config.middleware.use Rack::ActiveRecordStatus, :response => "I'm alive!" # A different response
39
+
40
+ For rails apps, a useful response is the REVISION file created by deployment tools (like Capistrano).
41
+
42
+ revision = Rails.root.join('REVISION').read rescue $!.to_s
43
+ config.middleware.use Rack::ActiveRecordStatus, :response => revision
35
44
 
36
45
  == Sponsorship
37
46
 
@@ -1,7 +1,12 @@
1
1
  module Rack
2
2
  class ActiveRecordStatus
3
- def initialize(app, path='/app_status')
4
- @app, @path = app, path
3
+ def initialize(app, options={})
4
+ @app = app
5
+ # Support legacy arguments (0.4.1 and below)
6
+ options = {:path => options} if options.is_a?(String)
7
+
8
+ @path = options[:path] || '/app_status'
9
+ @response = options[:response] || "OK\n"
5
10
  end
6
11
 
7
12
  def call(env)
@@ -14,9 +19,10 @@ module Rack
14
19
 
15
20
  def get_status
16
21
  begin
22
+ # Check that the application is connected to the database
17
23
  ActiveRecord::Base.connection.select_all('select 1')
18
24
  # Success
19
- [200, {'Content-Type' => 'text/plain'}, "OK #{Time.now}\n"]
25
+ [200, {'Content-Type' => 'text/plain'}, @response]
20
26
  rescue
21
27
  body = ['ERROR', "#{$!.class}: #{$!.message}", "Backtrace:"] + $!.backtrace
22
28
  body *= "\n"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rack-active_record_status'
3
- s.version = '0.4.1'
3
+ s.version = '0.5.0'
4
4
 
5
5
  s.summary = "Rack middelware to check ActiveRecord's connection"
6
6
  s.description = "A server health check for active_record."
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-active_record_status
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Suggs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-29 00:00:00 -04:00
18
+ date: 2011-10-05 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -111,8 +111,8 @@ extensions: []
111
111
  extra_rdoc_files:
112
112
  - README.rdoc
113
113
  files:
114
+ - .gitignore
114
115
  - Gemfile
115
- - Gemfile.lock
116
116
  - README.rdoc
117
117
  - Rakefile
118
118
  - lib/rack/active_record_status.rb
data/Gemfile.lock DELETED
@@ -1,38 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- rack-active_record_status (0.1)
5
- activerecord
6
- rack
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activemodel (3.0.7)
12
- activesupport (= 3.0.7)
13
- builder (~> 2.1.2)
14
- i18n (~> 0.5.0)
15
- activerecord (3.0.7)
16
- activemodel (= 3.0.7)
17
- activesupport (= 3.0.7)
18
- arel (~> 2.0.2)
19
- tzinfo (~> 0.3.23)
20
- activesupport (3.0.7)
21
- arel (2.0.9)
22
- builder (2.1.2)
23
- i18n (0.5.0)
24
- rack (1.2.2)
25
- rack-test (0.5.7)
26
- rack (>= 1.0)
27
- rake (0.8.7)
28
- shoulda (2.11.3)
29
- tzinfo (0.3.27)
30
-
31
- PLATFORMS
32
- ruby
33
-
34
- DEPENDENCIES
35
- rack-active_record_status!
36
- rack-test
37
- rake
38
- shoulda