leafy-rack 0.1.0 → 0.2.0

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: 32375b3191e4984cdda79aeaaae526f855cf073c
4
- data.tar.gz: 884c3eec470ff217b30bf0aa8c1fec7fed4a153e
3
+ metadata.gz: d3257ef3584e75e8be25b0a9dc774b54f77a418c
4
+ data.tar.gz: b951a09f4d372c74e8e38adbf3f75d9d18cfefa7
5
5
  SHA512:
6
- metadata.gz: 8a2b594c128067d6415ff542da326e467d2ea1acf8cf9bdfe2c82f78a487bbb335eb8c412eff89586ee3f345cee872ad435307957cf55eccfa559514dbaa5fe8
7
- data.tar.gz: 80ecea5eada8befc856236ec8361c28714aa4597057c4a4a0ac090b39a0bbb923c8f2ab088163b2532fe0ae41d70444ac509aed0aee3c1ddd0781d38298e9e3b
6
+ metadata.gz: fb7352d17da646bfd9dfd42f06520eb55b34d83ce86a19a4f7219482d08d94fa217bd0a4f7b66229b2dd347d34ccd1b7ecfe393b26f02aee98ef4b7a5f4c19ed
7
+ data.tar.gz: df971cb52eae50c57854b9a8eba34ed58716ab411523fa6269bdde112fb6345ef7ebc619caf3c698ef9fa8c6562050cbd74d9fa6fa509c0cdb36d7a90a1bddc6
@@ -1,20 +1,24 @@
1
1
  require 'leafy/rack'
2
2
  require 'leafy/json/health_writer'
3
+ require 'json' unless defined? :JSON
3
4
 
4
5
  module Leafy
5
6
  module Rack
6
7
  class Health
7
8
 
8
- WRITER = ::Leafy::Json::HealthWriter.new
9
-
10
9
  def self.response( health, env )
11
10
  data = health.run_health_checks
12
11
  is_healthy = data.values.all? { |r| r.healthy? }
12
+ json = if env[ 'QUERY_STRING' ] == 'pretty'
13
+ JSON.pretty_generate( data.to_hash )
14
+ else
15
+ data.to_hash.to_json
16
+ end
13
17
  [
14
- is_healthy ? 200 : 500,
18
+ is_healthy ? 200 : 503,
15
19
  { 'Content-Type' => 'application/json',
16
20
  'Cache-Control' => 'must-revalidate,no-cache,no-store' },
17
- [ WRITER.to_json( data, env[ 'QUERY_STRING' ] == 'pretty' ) ]
21
+ [ json ]
18
22
  ]
19
23
  end
20
24
 
@@ -1,6 +1,6 @@
1
1
  module Leafy
2
2
  module Rack
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
6
-
6
+
@@ -2,9 +2,9 @@
2
2
  require 'jar_dependencies'
3
3
 
4
4
  require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.4.0' )
5
+ require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.4.2' )
6
+ require_jar( 'io.dropwizard.metrics', 'metrics-json', '3.1.0' )
5
7
  require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.4.2' )
8
+ require_jar( 'io.dropwizard.metrics', 'metrics-core', '3.1.0' )
6
9
  require_jar( 'org.slf4j', 'slf4j-api', '1.7.7' )
7
10
  require_jar( 'io.dropwizard.metrics', 'metrics-jvm', '3.1.0' )
8
- require_jar( 'io.dropwizard.metrics', 'metrics-core', '3.1.0' )
9
- require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.4.2' )
10
- require_jar( 'io.dropwizard.metrics', 'metrics-json', '3.1.0' )
@@ -66,7 +66,7 @@ describe Leafy::Rack::Health do
66
66
 
67
67
  it 'has response' do
68
68
  status, headers, body = subject.response( health, {} )
69
- expect( status ).to eq 500
69
+ expect( status ).to eq 503
70
70
  expect( headers.to_yaml).to eq expected_headers.to_yaml
71
71
  body = JSON.parse( body.join )
72
72
  expect( body.to_yaml ).to eq report.to_yaml
@@ -74,7 +74,7 @@ describe Leafy::Rack::Health do
74
74
 
75
75
  it 'has pretty response' do
76
76
  status, headers, body = subject.response( health, { 'QUERY_STRING' => 'pretty' } )
77
- expect( status ).to eq 500
77
+ expect( status ).to eq 503
78
78
  expect( headers.to_yaml).to eq expected_headers.to_yaml
79
79
  expect( body.join.count( "\n" ) ).to eq 5
80
80
  body = JSON.parse( body.join )
@@ -103,7 +103,7 @@ describe Leafy::Rack::Health do
103
103
  status, headers, body = subject.call( env )
104
104
  expect( status ).to eq 200
105
105
  expect( headers.to_yaml).to eq expected_headers.to_yaml
106
- expect( body.join ).to eq '{ }'
106
+ expect( body.join.gsub( /\s/m, '' ) ).to eq '{}'
107
107
  end
108
108
  end
109
109
 
@@ -130,7 +130,7 @@ describe Leafy::Rack::Health do
130
130
  status, headers, body = subject.call( env )
131
131
  expect( status ).to eq 200
132
132
  expect( headers.to_yaml).to eq expected_headers.to_yaml
133
- expect( body.join ).to eq '{ }'
133
+ expect( body.join.gsub( /\s/m, '' ) ).to eq '{}'
134
134
  end
135
135
  end
136
136
  end
metadata CHANGED
@@ -1,108 +1,107 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leafy-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian meier
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-19 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: jar-dependencies
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ~>
18
17
  - !ruby/object:Gem::Version
19
18
  version: 0.1.8
20
- type: :runtime
19
+ name: jar-dependencies
21
20
  prerelease: false
21
+ type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.8
27
27
  - !ruby/object:Gem::Dependency
28
- name: leafy-metrics
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - "~>"
30
+ - - ~>
32
31
  - !ruby/object:Gem::Version
33
32
  version: 0.1.0
34
- type: :runtime
33
+ name: leafy-metrics
35
34
  prerelease: false
35
+ type: :runtime
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: leafy-health
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - "~>"
44
+ - - ~>
46
45
  - !ruby/object:Gem::Version
47
46
  version: 0.1.0
48
- type: :runtime
47
+ name: leafy-health
49
48
  prerelease: false
49
+ type: :runtime
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - "~>"
58
+ - - ~>
60
59
  - !ruby/object:Gem::Version
61
60
  version: 3.1.0
62
- type: :development
61
+ name: rspec
63
62
  prerelease: false
63
+ type: :development
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.1.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: yard
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - "~>"
72
+ - - ~>
74
73
  - !ruby/object:Gem::Version
75
74
  version: 0.8.7
76
- type: :development
75
+ name: yard
77
76
  prerelease: false
77
+ type: :development
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.8.7
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
- - - "~>"
86
+ - - ~>
88
87
  - !ruby/object:Gem::Version
89
88
  version: '10.2'
90
- type: :development
89
+ name: rake
91
90
  prerelease: false
91
+ type: :development
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '10.2'
97
- description: rack middleware to expose leafy metrics/health data as well a ping rack
98
- and a thread-dump rack
97
+ description: rack middleware to expose leafy metrics/health data as well a ping rack and a thread-dump rack
99
98
  email:
100
99
  - christian.meier@lookout.com
101
100
  executables: []
102
101
  extensions: []
103
102
  extra_rdoc_files: []
104
103
  files:
105
- - ".gitignore"
104
+ - .gitignore
106
105
  - Gemfile
107
106
  - LICENSE
108
107
  - README.md
@@ -138,26 +137,27 @@ homepage: https://github.com/lookout/leafy
138
137
  licenses:
139
138
  - MIT
140
139
  metadata: {}
141
- post_install_message:
140
+ post_install_message:
142
141
  rdoc_options: []
143
142
  require_paths:
144
143
  - lib
145
144
  required_ruby_version: !ruby/object:Gem::Requirement
146
145
  requirements:
147
- - - ">="
146
+ - - '>='
148
147
  - !ruby/object:Gem::Version
149
148
  version: '0'
150
149
  required_rubygems_version: !ruby/object:Gem::Requirement
151
150
  requirements:
152
- - - ">="
151
+ - - '>='
153
152
  - !ruby/object:Gem::Version
154
153
  version: '0'
155
154
  requirements:
156
155
  - jar io.dropwizard.metrics:metrics-json, 3.1.0
157
156
  - jar io.dropwizard.metrics:metrics-jvm, 3.1.0
158
- rubyforge_project:
157
+ rubyforge_project:
159
158
  rubygems_version: 2.4.5
160
- signing_key:
159
+ signing_key:
161
160
  specification_version: 4
162
161
  summary: rack middleware to expose leafy metrics/health data and more
163
162
  test_files: []
163
+ has_rdoc: