routemaster-client 1.2.3 → 1.3.1

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: 27996eccbf1d6410595449c47e40fe2f07d3bb38
4
- data.tar.gz: 40ca99661429c8b7718fb8d0f5df14d2eb98ac36
3
+ metadata.gz: 6bb45b1a23c8a5e90938bc4f7fb6d66593fd9dc3
4
+ data.tar.gz: e544d4fe87d288d07221d7d9822c853580a6ef31
5
5
  SHA512:
6
- metadata.gz: bf5f31e3cd2b89270a197c25713faad9497bd005991b22b021c6ec933bdba4e2e4c96539f54733457b875c1691cb7f7f3228d1d1dc6fe9e78dad706fa7b8e078
7
- data.tar.gz: b8d9a0003d7fb9f028be7a9fe21001b82e1f35e54be90ae3d7375dc43dd3f158190a77c17ae365378c08586edb67df01e5fc811a6583ef9e06eb5321561f2e25
6
+ metadata.gz: 2e10653bef8d65abbe10354a791dc27b444d0808ac789e24bda7cba5671f317e2fe2ba16c559b7e1335047651e6c17cddfcc08882a05072c16755be018d0d40e
7
+ data.tar.gz: 02af484562d4ab336398e83cdc5ee9843357d14b866f048cb23a457babbde5abd0e316f86795ab679cb2ac6e6b957b79009200bd60c7c02f71bc1628cf373dc0
@@ -7,3 +7,6 @@ rvm:
7
7
  - 2.3.1
8
8
  script:
9
9
  - bundle exec rspec
10
+ addons:
11
+ code_climate:
12
+ repo_token: b1d80c686f42ee5eb66895c4b0ac5c0d978e964d4700eae35aa0138f5a650c02
data/Gemfile CHANGED
@@ -13,3 +13,5 @@ gem 'guard-rspec'
13
13
  gem 'webmock'
14
14
  gem 'pry-nav'
15
15
  gem 'rack-test'
16
+ gem 'codeclimate-test-reporter', require: nil
17
+
@@ -1,19 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- routemaster-client (1.2.3)
4
+ routemaster-client (1.3.1)
5
5
  faraday (>= 0.9.0)
6
- net-http-persistent (~> 2.9.4)
7
- wisper (>= 1.6.1)
6
+ oj (~> 2.17)
7
+ typhoeus (~> 1.1)
8
+ wisper (~> 1.6.1)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
13
  addressable (2.4.0)
14
+ codeclimate-test-reporter (0.6.0)
15
+ simplecov (>= 0.7.1, < 1.0.0)
13
16
  coderay (1.1.1)
14
17
  crack (0.4.3)
15
18
  safe_yaml (~> 1.0.0)
16
19
  diff-lcs (1.2.5)
20
+ docile (1.1.5)
21
+ ethon (0.9.1)
22
+ ffi (>= 1.3.0)
17
23
  faraday (0.9.2)
18
24
  multipart-post (>= 1.2, < 3)
19
25
  ffi (1.9.12)
@@ -33,6 +39,7 @@ GEM
33
39
  guard-compat (~> 1.1)
34
40
  rspec (>= 2.99.0, < 4.0)
35
41
  hashdiff (0.3.0)
42
+ json (2.0.2)
36
43
  listen (3.0.8)
37
44
  rb-fsevent (~> 0.9, >= 0.9.4)
38
45
  rb-inotify (~> 0.9, >= 0.9.7)
@@ -41,10 +48,10 @@ GEM
41
48
  method_source (0.8.2)
42
49
  multipart-post (2.0.0)
43
50
  nenv (0.3.0)
44
- net-http-persistent (2.9.4)
45
51
  notiffany (0.1.0)
46
52
  nenv (~> 0.1)
47
53
  shellany (~> 0.0)
54
+ oj (2.17.4)
48
55
  pry (0.10.3)
49
56
  coderay (~> 1.1.0)
50
57
  method_source (~> 0.8.1)
@@ -75,8 +82,15 @@ GEM
75
82
  ruby_dep (1.3.1)
76
83
  safe_yaml (1.0.4)
77
84
  shellany (0.0.1)
85
+ simplecov (0.12.0)
86
+ docile (~> 1.1.0)
87
+ json (>= 1.8, < 3)
88
+ simplecov-html (~> 0.10.0)
89
+ simplecov-html (0.10.0)
78
90
  slop (3.6.0)
79
91
  thor (0.19.1)
92
+ typhoeus (1.1.0)
93
+ ethon (>= 0.9.0)
80
94
  webmock (2.1.0)
81
95
  addressable (>= 2.3.6)
82
96
  crack (>= 0.3.2)
@@ -88,6 +102,7 @@ PLATFORMS
88
102
 
89
103
  DEPENDENCIES
90
104
  bundler
105
+ codeclimate-test-reporter
91
106
  guard-rspec
92
107
  pry-nav
93
108
  psych
@@ -97,4 +112,4 @@ DEPENDENCIES
97
112
  webmock
98
113
 
99
114
  BUNDLED WITH
100
- 1.13.2
115
+ 1.12.5
data/README.md CHANGED
@@ -1,13 +1,8 @@
1
- # routemaster-client
1
+ ## routemaster-client [![Version](https://badge.fury.io/rb/routemaster-client.svg)](https://rubygems.org/gems/routemaster-client) [![Build](https://travis-ci.org/deliveroo/routemaster-client.svg?branch=master)](https://travis-ci.org/deliveroo/routemaster-client) [![Code Climate](https://codeclimate.com/github/deliveroo/routemaster-client/badges/gpa.svg)](https://codeclimate.com/github/deliveroo/routemaster-client) [![Test Coverage](https://codeclimate.com/github/deliveroo/routemaster-client/badges/coverage.svg)](https://codeclimate.com/github/deliveroo/routemaster-client/coverage) [![Docs](http://img.shields.io/badge/API%20docs-rubydoc.info-blue.svg)](http://rubydoc.info/github/deliveroo/routemaster-client/frames/file/README.md)
2
2
 
3
- A Ruby API for the [Routemaster](https://github.com/mezis/routemaster) event
3
+ A Ruby API for the [Routemaster](https://github.com/deliveroo/routemaster) event
4
4
  bus.
5
5
 
6
- [![Version](https://badge.fury.io/rb/routemaster-client.svg)](https://rubygems.org/gems/routemaster-client)
7
- &nbsp;
8
- [![Build](https://travis-ci.org/mezis/routemaster-client.svg?branch=master)](https://travis-ci.org/mezis/routemaster-client)
9
- &nbsp;
10
- [![Docs](http://img.shields.io/badge/API%20docs-rubydoc.info-blue.svg)](http://rubydoc.info/github/mezis/routemaster-client/frames/file/README.md)
11
6
 
12
7
 
13
8
  ## Installation
@@ -55,8 +50,14 @@ There are methods for the four canonical event types: `created`, `updated`,
55
50
  the publisher floods with `noop`s for all existing entities so subscribers can
56
51
  refresh their view of the domain.
57
52
 
53
+ A timestamp argument may be passed (it will be set by the bus automatically
54
+ otherwise); it must be an integer number of milliseconds since the UNIX Epoch:
58
55
 
59
- **Register** to be notified about `widgets` and `kitten` at most 60 seconds after
56
+ ```ruby
57
+ client.created('widgets', 'https://app.example.com/widgets/1', 1473080555409)
58
+ ```
59
+
60
+ **Subscribe** to be notified about `widgets` and `kitten` at most 60 seconds after
60
61
  events, in batches of at most 500 events, to a given callback URL:
61
62
 
62
63
  ```ruby
@@ -93,6 +94,24 @@ use Routemaster::Receiver, {
93
94
  This relies on the excellent event bus from the [wisper
94
95
  gem](https://github.com/krisleech/wisper#wisper).
95
96
 
97
+ **Unsubscribe** from a single topic:
98
+
99
+ ```ruby
100
+ client.unsubscribe('widgets')
101
+ ```
102
+
103
+ **Unsubscribe** from all topics:
104
+
105
+ ```ruby
106
+ client.unsubscribe_all
107
+ ```
108
+
109
+ **Delete** a topic (only possible if you're the emitter for this topic):
110
+
111
+ ```ruby
112
+ client.delete_topic('widgets')
113
+ ```
114
+
96
115
 
97
116
  **Monitor** the status of topics and subscriptions:
98
117
 
@@ -111,7 +130,7 @@ client.monitor_subscriptions
111
130
 
112
131
  ## Contributing
113
132
 
114
- 1. Fork it ( http://github.com/mezis/routemaster-client/fork )
133
+ 1. Fork it ( http://github.com/deliveroo/routemaster-client/fork )
115
134
  2. Create your feature branch (`git checkout -b my-new-feature`)
116
135
  3. Commit your changes (`git commit -am 'Add some feature'`)
117
136
  4. Push to the branch (`git push origin my-new-feature`)
@@ -9,14 +9,15 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Julien Letessier']
10
10
  spec.email = ['julien.letessier@gmail.com']
11
11
  spec.summary = %q{Client API for the Routemaster event bus}
12
- spec.homepage = 'http://github.com/mezis/routemaster-client'
12
+ spec.homepage = 'http://github.com/deliveroo/routemaster-client'
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
16
16
  spec.test_files = spec.files.grep(%r{^spec/})
17
17
  spec.require_paths = %w(.)
18
18
 
19
+ spec.add_runtime_dependency 'typhoeus', '~> 1.1'
19
20
  spec.add_runtime_dependency 'faraday', '>= 0.9.0'
20
- spec.add_runtime_dependency 'net-http-persistent', '~> 2.9.4'
21
- spec.add_runtime_dependency 'wisper', '>= 1.6.1'
21
+ spec.add_runtime_dependency 'wisper', '~> 1.6.1'
22
+ spec.add_runtime_dependency 'oj', '~> 2.17'
22
23
  end
@@ -1,16 +1,20 @@
1
1
  require 'routemaster/client/version'
2
- require 'routemaster/client/openssl'
3
2
  require 'routemaster/topic'
4
3
  require 'uri'
5
- require 'faraday'
6
4
  require 'json'
5
+ require 'faraday'
6
+ require 'typhoeus'
7
+ require 'typhoeus/adapters/faraday'
8
+ require 'oj'
7
9
 
8
10
  module Routemaster
9
11
  class Client
12
+
10
13
  def initialize(options = {})
11
14
  @_url = _assert_valid_url(options[:url])
12
15
  @_uuid = options[:uuid]
13
16
  @_timeout = options.fetch(:timeout, 1)
17
+ @_verify_ssl = options.fetch(:verify_ssl, true)
14
18
 
15
19
  _assert (options[:uuid] =~ /^[a-z0-9_-]{1,64}$/), 'uuid should be alpha'
16
20
  _assert_valid_timeout(@_timeout)
@@ -52,11 +56,41 @@ module Routemaster
52
56
 
53
57
  response = _post('/subscription') do |r|
54
58
  r.headers['Content-Type'] = 'application/json'
55
- r.body = options.to_json
59
+ r.body = Oj.dump(_stringify_keys options)
56
60
  end
57
- # $stderr.puts response.status
61
+
58
62
  unless response.success?
59
- raise 'subscription rejected'
63
+ raise 'subscribe rejected'
64
+ end
65
+ end
66
+
67
+ def unsubscribe(*topics)
68
+ topics.each { |t| _assert_valid_topic(t) }
69
+
70
+ topics.each do |t|
71
+ response = _delete("/subscriber/topics/#{t}")
72
+
73
+ unless response.success?
74
+ raise 'unsubscribe rejected'
75
+ end
76
+ end
77
+ end
78
+
79
+ def unsubscribe_all
80
+ response = _delete('/subscriber')
81
+
82
+ unless response.success?
83
+ raise 'unsubscribe all rejected'
84
+ end
85
+ end
86
+
87
+ def delete_topic(topic)
88
+ _assert_valid_topic(topic)
89
+
90
+ response = _delete("/topics/#{topic}")
91
+
92
+ unless response.success?
93
+ raise 'failed to delete topic'
60
94
  end
61
95
  end
62
96
 
@@ -69,7 +103,7 @@ module Routemaster
69
103
  raise 'failed to connect to /topics'
70
104
  end
71
105
 
72
- JSON(response.body).map do |raw_topic|
106
+ Oj.load(response.body).map do |raw_topic|
73
107
  Topic.new raw_topic
74
108
  end
75
109
  end
@@ -77,6 +111,14 @@ module Routemaster
77
111
 
78
112
  private
79
113
 
114
+ def _stringify_keys(hash)
115
+ hash.dup.tap do |h|
116
+ h.keys.each do |k|
117
+ h[k.to_s] = h.delete(k)
118
+ end
119
+ end
120
+ end
121
+
80
122
  def _assert_valid_timeout(timeout)
81
123
  _assert (0..3_600_000).include?(timeout), 'bad timeout'
82
124
  end
@@ -96,7 +138,7 @@ module Routemaster
96
138
  end
97
139
 
98
140
  def _assert_valid_timestamp(timestamp)
99
- _assert timestamp.is_a?(Numeric), 'not a numeric number'
141
+ _assert timestamp.kind_of?(Integer), 'not an integer'
100
142
  end
101
143
 
102
144
  def _send_event(event, topic, callback, timestamp = nil)
@@ -108,7 +150,7 @@ module Routemaster
108
150
 
109
151
  response = _post("/topics/#{topic}") do |r|
110
152
  r.headers['Content-Type'] = 'application/json'
111
- r.body = data.to_json
153
+ r.body = Oj.dump(_stringify_keys data)
112
154
  end
113
155
  fail "event rejected (#{response.status})" unless response.success?
114
156
  end
@@ -117,31 +159,27 @@ module Routemaster
117
159
  condition or raise ArgumentError.new(message)
118
160
  end
119
161
 
162
+ def _http(method, path, &block)
163
+ _conn.send(method, path, &block)
164
+ end
165
+
120
166
  def _post(path, &block)
121
- retries ||= 5
122
- _conn.post(path, &block)
123
- rescue Net::HTTP::Persistent::Error => e
124
- raise if (retries -= 1).zero?
125
- puts "warning: retrying post to #{path} on #{e.class.name}: #{e.message} (#{retries})"
126
- @_conn = nil
127
- retry
167
+ _http(:post, path, &block)
128
168
  end
129
169
 
130
170
  def _get(path, &block)
131
- retries ||= 5
132
- _conn.get(path, &block)
133
- rescue Net::HTTP::Persistent::Error => e
134
- raise if (retries -= 1).zero?
135
- puts "warning: retrying get to #{path} on #{e.class.name}: #{e.message} (#{retries})"
136
- @_conn = nil
137
- retry
171
+ _http(:get, path, &block)
172
+ end
173
+
174
+ def _delete(path, &block)
175
+ _http(:delete, path, &block)
138
176
  end
139
177
 
140
178
  def _conn
141
- @_conn ||= Faraday.new(@_url) do |f|
179
+ @_conn ||= Faraday.new(@_url, ssl: { verify: @_verify_ssl }) do |f|
142
180
  f.request :retry, max: 2, interval: 100e-3, backoff_factor: 2
143
181
  f.request :basic_auth, @_uuid, 'x'
144
- f.adapter :net_http_persistent
182
+ f.adapter :typhoeus
145
183
 
146
184
  f.options.timeout = @_timeout
147
185
  f.options.open_timeout = @_timeout
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  class Client
3
- VERSION = '1.2.3'
3
+ VERSION = '1.3.1'
4
4
  end
5
5
  end
@@ -23,7 +23,8 @@ module Routemaster
23
23
  throw :forward unless _intercept_endpoint?(env)
24
24
  return [401, {}, []] unless _has_auth?(env)
25
25
  return [403, {}, []] unless _valid_auth?(env)
26
- return [400, {}, []] unless payload = _extract_payload(env)
26
+ payload = _extract_payload(env)
27
+ return [400, {}, []] unless payload
27
28
 
28
29
  @handler.on_events(payload) if @handler
29
30
  publish(:events_received, payload)
@@ -4,9 +4,11 @@ require 'routemaster/topic'
4
4
  require 'webmock/rspec'
5
5
 
6
6
  describe Routemaster::Client do
7
- let(:options) do
8
- { url: 'https://bus.example.com', uuid: 'john_doe' }
9
- end
7
+ let(:options) {{
8
+ url: 'https://bus.example.com',
9
+ uuid: 'john_doe',
10
+ verify_ssl: false,
11
+ }}
10
12
  let(:pulse_response) { 204 }
11
13
 
12
14
  subject { described_class.new(options) }
@@ -130,7 +132,7 @@ describe Routemaster::Client do
130
132
  end
131
133
 
132
134
  context 'with explicit timestamp' do
133
- let(:timestamp) { Time.now.to_f }
135
+ let(:timestamp) { (Time.now.to_f * 1e3).to_i }
134
136
  let(:perform) { subject.send(event, topic, callback, timestamp) }
135
137
 
136
138
  before do
@@ -147,10 +149,18 @@ describe Routemaster::Client do
147
149
  expect(@stub).to have_been_requested
148
150
  end
149
151
 
150
- context 'with bad timestamp' do
152
+ context 'with non-numeric timestamp' do
151
153
  let(:timestamp) { 'foo' }
152
154
 
153
- it 'fails with non-numeric timestamp' do
155
+ it 'fails' do
156
+ expect { perform }.to raise_error(ArgumentError)
157
+ end
158
+ end
159
+
160
+ context 'with non-integer timestamp' do
161
+ let(:timestamp) { 123.45 }
162
+
163
+ it 'fails' do
154
164
  expect { perform }.to raise_error(ArgumentError)
155
165
  end
156
166
  end
@@ -231,6 +241,81 @@ describe Routemaster::Client do
231
241
  end
232
242
  end
233
243
 
244
+ describe '#unsubscribe' do
245
+ let(:perform) { subject.unsubscribe(*args) }
246
+ let(:args) {[
247
+ 'widgets'
248
+ ]}
249
+
250
+ before do
251
+ @stub = stub_request(:delete, %r{https://bus.example.com/subscriber/topics/widgets}).
252
+ with(basic_auth: [options[:uuid], 'x'])
253
+ end
254
+
255
+ it 'passes with correct arguments' do
256
+ expect { perform }.not_to raise_error
257
+ expect(@stub).to have_been_requested
258
+ end
259
+
260
+ it 'fails with a bad topic' do
261
+ args.replace ['foo123%bar']
262
+ expect { perform }.to raise_error(ArgumentError)
263
+ end
264
+
265
+ it 'fails on HTTP error' do
266
+ @stub.to_return(status: 500)
267
+ expect { perform }.to raise_error(RuntimeError)
268
+ end
269
+ end
270
+
271
+
272
+ describe '#unsubscribe_all' do
273
+ let(:perform) { subject.unsubscribe_all }
274
+
275
+ before do
276
+ @stub = stub_request(:delete, %r{https://bus.example.com/subscriber}).
277
+ with(basic_auth: [options[:uuid], 'x'])
278
+ end
279
+
280
+ it 'passes with correct arguments' do
281
+ expect { perform }.not_to raise_error
282
+ expect(@stub).to have_been_requested
283
+ end
284
+
285
+ it 'fails on HTTP error' do
286
+ @stub.to_return(status: 500)
287
+ expect { perform }.to raise_error(RuntimeError)
288
+ end
289
+ end
290
+
291
+ describe '#delete_topic' do
292
+ let(:perform) { subject.delete_topic(*args) }
293
+ let(:args) {[
294
+ 'widgets'
295
+ ]}
296
+
297
+ before do
298
+ @stub = stub_request(:delete, %r{https://bus.example.com/topics/widgets}).
299
+ with(basic_auth: [options[:uuid], 'x'])
300
+ end
301
+
302
+ it 'passes with correct arguments' do
303
+ expect { perform }.not_to raise_error
304
+ expect(@stub).to have_been_requested
305
+ end
306
+
307
+ it 'fails with a bad topic' do
308
+ args.replace ['foo123%bar']
309
+ expect { perform }.to raise_error(ArgumentError)
310
+ end
311
+
312
+ it 'fails on HTTP error' do
313
+ @stub.to_return(status: 500)
314
+ expect { perform }.to raise_error(RuntimeError)
315
+ end
316
+ end
317
+
318
+
234
319
  describe '#monitor_topics' do
235
320
 
236
321
  let(:perform) { subject.monitor_topics }
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  # This file was generated by the `rspec --init` command. Conventionally, all
2
5
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
6
  # Require this file using `require "spec_helper"` to ensure that it is only
@@ -13,4 +16,6 @@ RSpec.configure do |config|
13
16
  # the seed, which is printed after each run.
14
17
  # --seed 1234
15
18
  config.order = 'random'
19
+
20
+ config.after(:suite) { WebMock.disable! }
16
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routemaster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: typhoeus
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: faraday
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,33 +39,33 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: 0.9.0
27
41
  - !ruby/object:Gem::Dependency
28
- name: net-http-persistent
42
+ name: wisper
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 2.9.4
47
+ version: 1.6.1
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 2.9.4
54
+ version: 1.6.1
41
55
  - !ruby/object:Gem::Dependency
42
- name: wisper
56
+ name: oj
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 1.6.1
61
+ version: '2.17'
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 1.6.1
68
+ version: '2.17'
55
69
  description:
56
70
  email:
57
71
  - julien.letessier@gmail.com
@@ -71,10 +85,8 @@ files:
71
85
  - LICENSE.txt
72
86
  - README.md
73
87
  - Rakefile
74
- - core_ext/silence_stream.rb
75
88
  - routemaster-client.gemspec
76
89
  - routemaster/client.rb
77
- - routemaster/client/openssl.rb
78
90
  - routemaster/client/version.rb
79
91
  - routemaster/receiver.rb
80
92
  - routemaster/topic.rb
@@ -82,7 +94,7 @@ files:
82
94
  - spec/receiver_spec.rb
83
95
  - spec/spec_helper.rb
84
96
  - spec/topic_spec.rb
85
- homepage: http://github.com/mezis/routemaster-client
97
+ homepage: http://github.com/deliveroo/routemaster-client
86
98
  licenses:
87
99
  - MIT
88
100
  metadata: {}
@@ -1,13 +0,0 @@
1
- # Adapted from
2
- # activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 44
3
- class IO
4
- def silence_stream(&block)
5
- old_stream = dup
6
- self.reopen('/dev/null')
7
- self.sync = true
8
- yield
9
- ensure
10
- reopen(old_stream)
11
- old_stream.close
12
- end
13
- end
@@ -1,21 +0,0 @@
1
- # In development environments, engineers will typically use self-signed
2
- # certificates as it it not realistic to have valid cert chains for localhost
3
- # or fake domains.
4
- #
5
- # This code disables SSL cert verification, and silences net-http-persistent's
6
- # unnecessary warning.
7
- #
8
- # Note that this does _not_ apply in production or staging.
9
- #
10
- # http://docs.seattlerb.org/net-http-persistent/History_txt.html#documentation
11
- # http://www.rubyinside.com/how-to-cure-nethttps-risky-default-https-behavior-4010.html
12
- if ENV.fetch('RACK_ENV', 'development') !~ /production|staging/
13
- require 'openssl'
14
- require 'core_ext/silence_stream'
15
-
16
- I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG = nil
17
-
18
- $stderr.silence_stream do
19
- OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
20
- end
21
- end