rack-active_record_status 0.1
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/Gemfile +3 -0
- data/Gemfile.lock +38 -0
- data/README.rdoc +49 -0
- data/Rakefile +11 -0
- data/lib/rack/active_record_status.rb +27 -0
- data/rack-active_record_status.gemspec +39 -0
- data/test/helper.rb +7 -0
- metadata +157 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
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
|
data/README.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
= Active Record Rack Status
|
2
|
+
|
3
|
+
Lightweight Rack Middleware for testing active record connections
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install rack-active_record_status
|
8
|
+
|
9
|
+
== Basic Usage
|
10
|
+
|
11
|
+
require 'rack/active_record_status'
|
12
|
+
use Rack::ActiveRecordStatus
|
13
|
+
|
14
|
+
Or, if you are using Bundler, just add this to your Gemfile:
|
15
|
+
|
16
|
+
gem 'rack-active_record_status'
|
17
|
+
|
18
|
+
To use Rack::ActiveRecordStatus in your Rails application, add the following line to your application
|
19
|
+
config file (<tt>config/application.rb</tt> for Rails 3, <tt>config/environment.rb</tt> for Rails 2):
|
20
|
+
|
21
|
+
config.middleware.use Rack::ActiveRecordStatus
|
22
|
+
|
23
|
+
== Sponsorship
|
24
|
+
|
25
|
+
All new work on active_record_rack_status is sponsored by {Medidata Solutions}[http://github.com/mdsol]
|
26
|
+
== Copyright
|
27
|
+
|
28
|
+
(The MIT License)
|
29
|
+
|
30
|
+
Copyright (c) 2011 {Aaron Suggs}[http://github.com/ktheory]
|
31
|
+
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
33
|
+
a copy of this software and associated documentation files (the
|
34
|
+
"Software"), to deal in the Software without restriction, including
|
35
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
36
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
37
|
+
permit persons to whom the Software is furnished to do so, subject to
|
38
|
+
the following conditions:
|
39
|
+
|
40
|
+
The above copyright notice and this permission notice shall be
|
41
|
+
included in all copies or substantial portions of the Software.
|
42
|
+
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
44
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
45
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
46
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
47
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
48
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
49
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rack
|
2
|
+
class ActiveRecordStatus
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
if env['PATH_INFO'] == '/active_record_status'
|
9
|
+
get_status
|
10
|
+
else
|
11
|
+
@app.call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_status
|
16
|
+
begin
|
17
|
+
ActiveRecord::Base.connection.select_all('select 1')
|
18
|
+
body = "OK #{Time.now}"
|
19
|
+
[200, {'Content-Type' => 'text/plain'}, body]
|
20
|
+
rescue
|
21
|
+
body = ['ERROR', "#{$!.class}: #{$!.message}", "Backtrace:"] + $!.backtrace
|
22
|
+
body *= "\n"
|
23
|
+
[500, {'Content-Type' => 'text/plain'}, body]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'rack-active_record_status'
|
3
|
+
s.version = '0.1'
|
4
|
+
|
5
|
+
s.summary = "Rack middelware to check ActiveRecord's connection"
|
6
|
+
s.description = "A server health check for active_record."
|
7
|
+
|
8
|
+
s.authors = ["Aaron Suggs"]
|
9
|
+
s.email = 'aaron@ktheory.com'
|
10
|
+
s.homepage = 'http://github.com/ktheory/active_record_rack_status'
|
11
|
+
s.required_rubygems_version = ">= 1.3.5"
|
12
|
+
|
13
|
+
## This sections is only necessary if you have C extensions.
|
14
|
+
# s.require_paths << 'ext'
|
15
|
+
# s.extensions = %w[ext/extconf.rb]
|
16
|
+
|
17
|
+
## If your gem includes any executables, list them here.
|
18
|
+
s.executables = []
|
19
|
+
|
20
|
+
## Specify any RDoc options here. You'll want to add your README and
|
21
|
+
## LICENSE files to the extra_rdoc_files list.
|
22
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
23
|
+
s.extra_rdoc_files = %w[README.rdoc]
|
24
|
+
|
25
|
+
## List your runtime dependencies here. Runtime dependencies are those
|
26
|
+
## that are needed for an end user to actually USE your code.
|
27
|
+
s.add_dependency 'rack'
|
28
|
+
s.add_dependency 'activerecord'
|
29
|
+
|
30
|
+
## List your development dependencies here. Development dependencies are
|
31
|
+
## those that are only needed during development
|
32
|
+
s.add_development_dependency 'rake'
|
33
|
+
s.add_development_dependency 'rake'
|
34
|
+
s.add_development_dependency 'shoulda'
|
35
|
+
s.add_development_dependency 'rack-test'
|
36
|
+
|
37
|
+
s.files = `git ls-files`.split("\n")
|
38
|
+
s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
|
39
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-active_record_status
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Aaron Suggs
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-02 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rack
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: activerecord
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: shoulda
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :development
|
89
|
+
version_requirements: *id005
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: rack-test
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id006
|
104
|
+
description: A server health check for active_record.
|
105
|
+
email: aaron@ktheory.com
|
106
|
+
executables: []
|
107
|
+
|
108
|
+
extensions: []
|
109
|
+
|
110
|
+
extra_rdoc_files:
|
111
|
+
- README.rdoc
|
112
|
+
files:
|
113
|
+
- Gemfile
|
114
|
+
- Gemfile.lock
|
115
|
+
- README.rdoc
|
116
|
+
- Rakefile
|
117
|
+
- lib/rack/active_record_status.rb
|
118
|
+
- rack-active_record_status.gemspec
|
119
|
+
- test/helper.rb
|
120
|
+
has_rdoc: true
|
121
|
+
homepage: http://github.com/ktheory/active_record_rack_status
|
122
|
+
licenses: []
|
123
|
+
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options:
|
126
|
+
- --charset=UTF-8
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
version: "0"
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 17
|
144
|
+
segments:
|
145
|
+
- 1
|
146
|
+
- 3
|
147
|
+
- 5
|
148
|
+
version: 1.3.5
|
149
|
+
requirements: []
|
150
|
+
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 1.6.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 3
|
155
|
+
summary: Rack middelware to check ActiveRecord's connection
|
156
|
+
test_files: []
|
157
|
+
|