rack-heartbeat 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rack::Heartbeat
2
2
 
3
- TODO: Write a gem description
3
+ A tiny gem that installs a Rack middleware to respond to heartbeat requests. This saves you all the trouble of creating custom controllers, routes, and static files, and prevents your logs from bloating.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,16 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Once the gem is installed, you're done. Just browse to localhost:300/heartbeat to get a text response with "OK".
22
+
23
+ If you want to customize the url for any reason, you can configure that, too:
24
+
25
+ ```ruby
26
+ #config/initilializers/rack_heartbeat.rb
27
+ Rack::Heartbeat.setup do |config|
28
+ config.heartbeat_path = 'health-check.txt'
29
+ end
30
+ ```
22
31
 
23
32
  ## Contributing
24
33
 
@@ -27,3 +36,8 @@ TODO: Write usage instructions here
27
36
  3. Commit your changes (`git commit -am 'Added some feature'`)
28
37
  4. Push to the branch (`git push origin my-new-feature`)
29
38
  5. Create new Pull Request
39
+
40
+ ## Contributors
41
+
42
+ * [James Cox](https://github.com/imajes)
43
+ * [Steve Mitchell](http://github.com/theSteveMitchell)
@@ -1,17 +1,25 @@
1
1
  module Rack
2
2
  # A heartbeat mechanism for the server. This will add a _/heartbeat_ endpoint
3
3
  # that returns status 200 and content OK when executed.
4
+
4
5
  class Heartbeat
6
+ cattr_accessor :heartbeat_path
7
+ @@heartbeat_path = 'heartbeat'
8
+
5
9
  def initialize(app)
6
10
  @app = app
7
11
  end
8
12
 
9
13
  def call(env)
10
- if env['PATH_INFO'] == '/heartbeat'
11
- [200, {}, ['OK']]
14
+ if env['PATH_INFO'] == "/#{heartbeat_path}"
15
+ [200, {"Content-Type" => "text/plain"}, ["OK"]]
12
16
  else
13
17
  @app.call(env)
14
18
  end
15
19
  end
20
+
21
+ def self.setup
22
+ yield self
23
+ end
16
24
  end
17
25
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
14
  gem.name = "rack-heartbeat"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = '0.6'
16
+ gem.version = '0.7'
17
17
 
18
18
  # deps
19
19
  gem.add_dependency('rack')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-heartbeat
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2014-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 1.8.24
67
+ rubygems_version: 1.8.25
68
68
  signing_key:
69
69
  specification_version: 3
70
70
  summary: provides a simple endpoint for your rails app for a heartbeat client to connect