rack-ecg 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f59a0b33808baa8d2e2e9fce089e2cfdf03668c
4
- data.tar.gz: 3cc238f62ea9afc55dccea25814b24aecc9975aa
3
+ metadata.gz: 6e69b8b06f6e9447931c2dd5f6a709153fc05054
4
+ data.tar.gz: 7fd824b68af2e6db167af65b7518004c1c7aabce
5
5
  SHA512:
6
- metadata.gz: f122cef317b2d199fe20075495826a9581af55042addceb61e7ce3f9a32ffb92f3a566590e4b2afa33ee78ca00da9b624265ae9fa1d06363066edb452da64944
7
- data.tar.gz: 2cf179f722e4024aaf52c3a5c10d676e083a88c4a1b5b5fdc3b6cd63ed5ec9b7c5cf85f384bc35504a95aed0e085e73335638514c1d9b2aae3848728c36622d4
6
+ metadata.gz: 80b858e5dbf7874a6db6d70361c7f8c5726b515113e3bece707c9c857ed70d0d14448ee640899433f7bc4206458cb418b23b03b66d72e32b18c2b5a347c2bcc8
7
+ data.tar.gz: 6fa5476c8cba27af405f0c648be87843d79c89f166328ca0b8b15368f3d8cb1b8c3fda15ddc0c850e8d5b66711635c1ca02193001e5cd514fe43074599f8582d
@@ -1,15 +1,28 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+
2
5
  rvm:
3
6
  - 1.9.3
4
- - 2.0.0
5
- - 2.1.5
6
- - 2.2.1
7
+ - 2.0
8
+ - 2.1
9
+ - 2.2.5
10
+ - 2.3.1
7
11
  - ruby-head
8
12
  - jruby
9
- notifications:
10
- webhooks:
11
- urls:
12
- - https://webhooks.gitter.im/e/b627d6a74f88be59d0b9
13
- on_success: change # options: [always|never|change] default: always
14
- on_failure: always # options: [always|never|change] default: always
15
- on_start: false # default: false - rbx-2
13
+
14
+ gemfile:
15
+ - Gemfile
16
+ - gemfiles/rack_v1.gemfile
17
+
18
+ matrix:
19
+ allow_failures:
20
+ - rvm: ruby-head
21
+ - rvm: jruby
22
+ exclude:
23
+ - rvm: 1.9.3
24
+ gemfile: Gemfile
25
+ - rvm: 2.0
26
+ gemfile: Gemfile
27
+ - rvm: 2.1
28
+ gemfile: Gemfile
data/README.md CHANGED
@@ -145,7 +145,13 @@ migrations stored in `schema_versions` table
145
145
 
146
146
  ## Maintainers
147
147
 
148
+ - [Tao Guo](https://github.com/taoza)
149
+ - [Warren Seen](https://github.com/warrenseen)
150
+
151
+ ## Authors
152
+
148
153
  - [Julian Doherty](https://github.com/madlep)
154
+ - [Warren Seen](https://github.com/warrenseen)
149
155
 
150
156
  ## License
151
157
 
@@ -168,4 +174,17 @@ For bug fixes, documentation changes, and small features:
168
174
  4. Push to the branch (git push origin my-new-feature)
169
175
  5. Create a new Pull Request
170
176
 
171
- For larger new features: Do everything as above, but first also make contact with the project maintainers to be sure your change fits with the project direction and you won't be wasting effort going in the wrong direction
177
+ For larger new features: Do everything as above, but first also make contact with the project maintainers to be sure your change fits with the project direction and you won't be wasting effort going in the wrong direction.
178
+
179
+ ## About
180
+
181
+ This project is maintained by the [Envato engineering team][webuild] and funded by [Envato][envato].
182
+
183
+ [<img src="http://opensource.envato.com/images/envato-oss-readme-logo.png" alt="Envato logo">][envato]
184
+
185
+ Encouraging the use and creation of open source software is one of the ways we serve our community. See [our other projects][oss] or [come work with us][careers] where you'll find an incredibly diverse, intelligent and capable group of people who help make our company succeed and make our workplace fun, friendly and happy.
186
+
187
+ [webuild]: http://webuild.envato.com?utm_source=github
188
+ [envato]: https://envato.com?utm_source=github
189
+ [oss]: http://opensource.envato.com//?utm_source=github
190
+ [careers]: http://careers.envato.com/?utm_source=github
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rack', '< 2'
4
+ gemspec path: '../'
@@ -15,6 +15,8 @@ module Rack
15
15
  @check_classes = build_check_classes(check_names)
16
16
 
17
17
  @at = options.delete(:at) || DEFAULT_MOUNT_AT
18
+
19
+ @hook = options.delete(:hook)
18
20
  end
19
21
 
20
22
  def call(env)
@@ -25,7 +27,11 @@ module Rack
25
27
  results.merge(check.result.to_json)
26
28
  }
27
29
 
28
- response_status = check_results.any?{|check| check[1][:status] == "error" } ? 500 : 200
30
+ success = check_results.none? { |check| check[1][:status] == "error" }
31
+
32
+ response_status = success ? 200 : 500
33
+
34
+ @hook.call(success, check_results) if @hook
29
35
 
30
36
  response_headers = {
31
37
  "X-Rack-ECG-Version" => Rack::ECG::VERSION,
@@ -8,9 +8,7 @@ module Rack
8
8
  begin
9
9
  if defined?(ActiveRecord)
10
10
  connection = ActiveRecord::Base.connection
11
- result_set = connection.execute("select max(version) as version from schema_migrations")
12
- version = result_set.first
13
- value = version["version"]
11
+ value = connection.select_value("select max(version) from schema_migrations")
14
12
  else
15
13
  status = "error"
16
14
  value = "ActiveRecord not found"
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class ECG
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -70,6 +70,22 @@ RSpec.describe "when used as middleware" do
70
70
  end
71
71
  end
72
72
 
73
+ context "when hook config option is set" do
74
+ let(:hook_proc) { instance_double(Proc) }
75
+ let(:options) {
76
+ { hook: hook_proc, checks: :error }
77
+ }
78
+
79
+ it "executes the hook proc with success status and check results as params" do
80
+ expect(hook_proc).to receive(:call) do |success, check_results|
81
+ expect(success).to be_falsey
82
+ expect(check_results).to have_key(:error)
83
+ end
84
+ get "_ecg"
85
+ expect(last_response.status).to eq(500)
86
+ end
87
+ end
88
+
73
89
  context "git revision" do
74
90
  let(:options) {
75
91
  { checks: [:git_revision] }
@@ -124,9 +140,9 @@ RSpec.describe "when used as middleware" do
124
140
  version = "123456"
125
141
  connection = double("connection")
126
142
  expect(ActiveRecord::Base).to receive(:connection).and_return(connection)
127
- expect(connection).to receive(:execute).
128
- with("select max(version) as version from schema_migrations").
129
- and_return([{"version" => version}])
143
+ expect(connection).to receive(:select_value).
144
+ with("select max(version) from schema_migrations").
145
+ and_return(version)
130
146
  get "/_ecg"
131
147
  expect(json_body["migration_version"]["status"]).to eq("ok")
132
148
  expect(json_body["migration_version"]["value"]).to eq(version)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-ecg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Envato
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-17 00:00:00.000000000 Z
12
+ date: 2017-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -116,6 +116,7 @@ files:
116
116
  - examples/checks.ru
117
117
  - examples/mounted_path.ru
118
118
  - examples/stand_alone.ru
119
+ - gemfiles/rack_v1.gemfile
119
120
  - lib/rack-ecg.rb
120
121
  - lib/rack/ecg.rb
121
122
  - lib/rack/ecg/check.rb
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  version: '0'
149
150
  requirements: []
150
151
  rubyforge_project:
151
- rubygems_version: 2.4.5
152
+ rubygems_version: 2.4.5.2
152
153
  signing_key:
153
154
  specification_version: 4
154
155
  summary: Rack middleware serving a health check page