okcomputer 0.3.0 → 0.3.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/app/controllers/ok_computer_controller.rb +13 -6
- data/config/routes.rb +3 -3
- data/lib/okcomputer/version.rb +1 -1
- metadata +4 -4
@@ -1,12 +1,12 @@
|
|
1
1
|
class OkComputerController < ActionController::Base
|
2
2
|
layout nil
|
3
|
-
respond_to :text, :json
|
3
|
+
respond_to :text, :html, :json
|
4
4
|
|
5
5
|
before_filter :authenticate
|
6
6
|
|
7
7
|
rescue_from OKComputer::Registry::CheckNotFound do |e|
|
8
8
|
respond_to do |f|
|
9
|
-
f.text { render text: e.message, status: :not_found }
|
9
|
+
f.any(:text, :html) { render text: e.message, status: :not_found }
|
10
10
|
f.json { render json: { error: e.message }, status: :not_found }
|
11
11
|
end
|
12
12
|
end
|
@@ -15,20 +15,28 @@ class OkComputerController < ActionController::Base
|
|
15
15
|
checks = OKComputer::Registry.all
|
16
16
|
checks.run
|
17
17
|
|
18
|
-
|
18
|
+
respond checks, status_code(checks)
|
19
19
|
end
|
20
20
|
|
21
21
|
def show
|
22
22
|
check = OKComputer::Registry.fetch(params[:check])
|
23
23
|
check.run
|
24
24
|
|
25
|
-
|
25
|
+
respond check, status_code(check)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def respond(data, status)
|
31
|
+
respond_to do |format|
|
32
|
+
format.any(:text, :html) { render text: data, status: status }
|
33
|
+
format.json { render json: data, status: status }
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
37
|
def status_code(check)
|
29
38
|
check.success? ? :ok : :error
|
30
39
|
end
|
31
|
-
private :status_code
|
32
40
|
|
33
41
|
def authenticate
|
34
42
|
if OKComputer.requires_authentication?
|
@@ -37,5 +45,4 @@ class OkComputerController < ActionController::Base
|
|
37
45
|
end
|
38
46
|
end
|
39
47
|
end
|
40
|
-
private :authenticate
|
41
48
|
end
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
match "/okcomputer" => "ok_computer#show", defaults: {check: "default"
|
3
|
-
match "/okcomputer/all
|
4
|
-
match "/okcomputer
|
2
|
+
match "/okcomputer" => "ok_computer#show", defaults: {check: "default"}
|
3
|
+
match "/okcomputer/all" => "ok_computer#index"
|
4
|
+
match "/okcomputer/:check" => "ok_computer#show"
|
5
5
|
end
|
data/lib/okcomputer/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: okcomputer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Patrick Byrne
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash: -
|
103
|
+
hash: -124086234721425557
|
104
104
|
none: false
|
105
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash: -
|
112
|
+
hash: -124086234721425557
|
113
113
|
none: false
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|