pingable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright © 2011 Alexander Staubo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- Pinger
2
- ======
1
+ Pingable
2
+ ========
3
3
 
4
- Pinger is a simple framework to implement a 'ping' URL in Rack-based web applications.
4
+ Pingable is a simple framework to implement a 'ping' URL in Rack-based web applications.
5
5
 
6
6
  For example, a Rails or Sinatra app's `config.ru` may look like this:
7
7
 
@@ -18,6 +18,18 @@ Now you can add checks in a modular fashion:
18
18
  end
19
19
  }
20
20
 
21
+ Checks
22
+ ------
23
+
24
+ A check is simply an object which:
25
+
26
+ * implements `call` with no arguments.
27
+ * returns one of the following on error:
28
+ * a string
29
+ * a hash of `{:message => message}`
30
+ * an array of the above
31
+ * returns nil on success.
32
+
21
33
  Something a bit more complex:
22
34
 
23
35
  class TwitterCheck
@@ -32,14 +44,24 @@ Something a bit more complex:
32
44
 
33
45
  Pingable.add_check TwitterCheck.new(:url => "http://twitter.com/")
34
46
 
35
- A check is simply an object which:
47
+ Configuration
48
+ -------------
36
49
 
37
- * implements `call` with no arguments.
38
- * returns one of the following on error:
39
- * a string
40
- * a hash of {:message => message}
41
- * an array of the above
42
- * returns nil on success.
50
+ To set the name that a successful ping check will return, provide a name in the rackup file:
51
+
52
+ map '/ping' do
53
+ use Pingable::Handler, 'my fancy app'
54
+ end
55
+ run MyApp
56
+
57
+ Ping check
58
+ ----------
59
+
60
+ `/ping` is implemented by running all registered checks.
61
+
62
+ On failure, an HTTP `500` is returned, with the body of the response being a `text/plain` text with each error on separate lines.
63
+
64
+ On success, a `200 OK` is returned, with either the application's name as the body (if defined), or an empty body.
43
65
 
44
66
  Common checks
45
67
  -------------
@@ -52,3 +74,10 @@ These include:
52
74
 
53
75
  * A check to verify ActiveRecord's current connection.
54
76
  * A check to check the ability for Rails' cache to read and write values.
77
+
78
+ Common checks for are only installed for dependencies that are discovered automatically. For example, if ActiveRecord has not been `require`d, then the ActiveRecord check is not included.
79
+
80
+ License
81
+ -------
82
+
83
+ Licensed under the MIT license. See `LICENSE` file.
@@ -7,7 +7,7 @@ Pingable.add_check lambda {
7
7
  }
8
8
 
9
9
  map '/ping' do
10
- use Pingable::Handler
10
+ use Pingable::Handler, "myapp"
11
11
  end
12
12
  run lambda { |env|
13
13
  [200, {'Content-Type' => 'text/plain'}, ['OK']]
@@ -2,8 +2,9 @@ module Pingable
2
2
 
3
3
  class Handler
4
4
 
5
- def initialize(app)
5
+ def initialize(app, name = nil)
6
6
  @app = app
7
+ @name = name
7
8
  end
8
9
 
9
10
  def call(env)
@@ -11,15 +12,13 @@ module Pingable
11
12
  if failures.any?
12
13
  [500, HEADERS, failures.map { |f| f[:message] }.join("\n")]
13
14
  else
14
- app_name = env['pingable.name']
15
- app_name ||= ''
16
- [200, HEADERS, app_name]
15
+ [200, HEADERS, @name ||= '']
17
16
  end
18
17
  end
19
18
 
20
19
  private
21
20
 
22
- HEADERS = {'Cache-Control' => 'private'}
21
+ HEADERS = {'Cache-Control' => 'private', 'Content-Type': 'text/plain'}
23
22
 
24
23
  end
25
24
 
@@ -1,3 +1,3 @@
1
1
  module Pingable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Alexander Staubo"]
10
10
  s.email = ["alex@origo.no"]
11
11
  s.homepage = "http://github.com/origo/pingable"
12
- s.summary = s.description = %q{Pingable is a Rack handler that let an app respond to a path /ping, with pluggable checks}
12
+ s.summary = s.description = %q{Pingable is a Rack handler that let an app respond to a path /ping, with pluggable checks.}
13
13
 
14
14
  s.rubyforge_project = "pingable"
15
15
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pingable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexander Staubo
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 1.0.0
48
48
  type: :runtime
49
49
  version_requirements: *id002
50
- description: Pingable is a Rack handler that let an app respond to a path /ping, with pluggable checks
50
+ description: Pingable is a Rack handler that let an app respond to a path /ping, with pluggable checks.
51
51
  email:
52
52
  - alex@origo.no
53
53
  executables: []
@@ -59,6 +59,7 @@ extra_rdoc_files: []
59
59
  files:
60
60
  - .gitignore
61
61
  - Gemfile
62
+ - LICENSE
62
63
  - README.md
63
64
  - Rakefile
64
65
  - example/config.ru
@@ -100,6 +101,6 @@ rubyforge_project: pingable
100
101
  rubygems_version: 1.8.6
101
102
  signing_key:
102
103
  specification_version: 3
103
- summary: Pingable is a Rack handler that let an app respond to a path /ping, with pluggable checks
104
+ summary: Pingable is a Rack handler that let an app respond to a path /ping, with pluggable checks.
104
105
  test_files: []
105
106