routemaster-drain 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +19 -0
  3. data/.env.test +2 -2
  4. data/.rubocop.yml +1156 -0
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +8 -0
  7. data/Appraisals +3 -3
  8. data/CHANGELOG.md +31 -5
  9. data/Gemfile +7 -6
  10. data/Gemfile.lock +23 -17
  11. data/README.md +19 -0
  12. data/appraise +28 -0
  13. data/gemfiles/rails_3.gemfile +8 -8
  14. data/gemfiles/rails_3.gemfile.lock +64 -58
  15. data/gemfiles/rails_4.gemfile +8 -8
  16. data/gemfiles/rails_4.gemfile.lock +121 -92
  17. data/gemfiles/rails_5.gemfile +8 -8
  18. data/gemfiles/rails_5.gemfile.lock +78 -72
  19. data/lib/core_ext/forwardable.rb +14 -0
  20. data/lib/routemaster/api_client.rb +65 -36
  21. data/lib/routemaster/cache.rb +7 -1
  22. data/lib/routemaster/cache_key.rb +7 -0
  23. data/lib/routemaster/config.rb +12 -13
  24. data/lib/routemaster/dirty/map.rb +1 -1
  25. data/lib/routemaster/drain.rb +1 -1
  26. data/lib/routemaster/event_index.rb +21 -0
  27. data/lib/routemaster/jobs.rb +2 -0
  28. data/lib/routemaster/jobs/cache_and_sweep.rb +2 -1
  29. data/lib/routemaster/jobs/job.rb +2 -0
  30. data/lib/routemaster/middleware/cache.rb +2 -5
  31. data/lib/routemaster/middleware/parse.rb +2 -2
  32. data/lib/routemaster/middleware/response_caching.rb +54 -24
  33. data/lib/routemaster/null_logger.rb +16 -0
  34. data/lib/routemaster/redis_broker.rb +8 -7
  35. data/lib/routemaster/resources/rest_resource.rb +18 -7
  36. data/lib/routemaster/responses/future_response.rb +37 -17
  37. data/lib/routemaster/responses/hateoas_enumerable_response.rb +47 -0
  38. data/lib/routemaster/responses/hateoas_response.rb +9 -12
  39. data/routemaster-drain.gemspec +2 -2
  40. data/spec/routemaster/api_client_spec.rb +118 -44
  41. data/spec/routemaster/drain/caching_spec.rb +4 -3
  42. data/spec/routemaster/integration/api_client_spec.rb +266 -102
  43. data/spec/routemaster/integration/cache_spec.rb +52 -39
  44. data/spec/routemaster/middleware/cache_spec.rb +4 -6
  45. data/spec/routemaster/redis_broker_spec.rb +11 -11
  46. data/spec/routemaster/resources/rest_resource_spec.rb +4 -2
  47. data/spec/routemaster/responses/future_response_spec.rb +18 -0
  48. data/spec/routemaster/responses/hateoas_enumerable_response_spec.rb +78 -0
  49. data/spec/routemaster/responses/hateoas_response_spec.rb +52 -53
  50. data/spec/spec_helper.rb +2 -1
  51. data/spec/support/breakpoint_class.rb +14 -0
  52. data/spec/support/server.rb +52 -0
  53. data/spec/support/uses_redis.rb +2 -2
  54. metadata +26 -10
  55. data/test.rb +0 -17
@@ -1,9 +1,10 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start
3
3
 
4
- require 'byebug'
5
4
  require 'sidekiq/testing'
6
5
  require 'dotenv'
6
+ require 'pry'
7
+ require 'byebug'
7
8
  Dotenv.overload('.env.test')
8
9
 
9
10
  # This file was generated by the `rspec --init` command. Conventionally, all
@@ -0,0 +1,14 @@
1
+ require 'fork_break'
2
+
3
+ def breakpoint_class(klass, method_name)
4
+ breakpoint_prepend = Module.new do
5
+ define_method(method_name) do | *args |
6
+ breakpoints << :"before_#{method_name}"
7
+ result = super(*args)
8
+ breakpoints << :"after_#{method_name}"
9
+ return result
10
+ end
11
+ end
12
+ klass.include(ForkBreak::Breakpoints)
13
+ klass.prepend(breakpoint_prepend)
14
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'timeout'
3
+ require 'webrick'
4
+
5
+ # Patch WEBrick as it doesn't support PATCH (?)
6
+ module WEBrick
7
+ module HTTPServlet
8
+ class ProcHandler
9
+ alias do_PATCH do_GET
10
+ end
11
+ end
12
+ end
13
+
14
+ class TestServer
15
+ def initialize(port, &block)
16
+ @port = port
17
+ @setup = block
18
+ end
19
+
20
+ def start
21
+ return if @pid
22
+ @pid = fork do
23
+ WEBrick::HTTPServer.new(
24
+ Port: @port,
25
+ DocumentRoot: Dir.pwd,
26
+ Logger: WEBrick::Log.new('/dev/null'),
27
+ AccessLog: [nil, nil]
28
+ ).tap do |server|
29
+ @setup.call(server)
30
+ server.start
31
+ end
32
+ end
33
+
34
+ # wait until the child server is up
35
+ Timeout.timeout(5) do
36
+ loop do
37
+ begin
38
+ TCPSocket.new('localhost', '8000')
39
+ rescue Errno::ECONNREFUSED
40
+ next
41
+ end
42
+ break
43
+ end
44
+ end
45
+ end
46
+
47
+ def stop
48
+ return unless @pid
49
+ Process.kill('KILL', @pid)
50
+ Process.wait(@pid)
51
+ end
52
+ end
@@ -7,8 +7,8 @@ module RspecSupportUsesRedis
7
7
  uses_dotenv
8
8
 
9
9
  let(:redis) { Routemaster::Config.drain_redis }
10
- before { Routemaster::Config.cache_redis.flushdb }
11
- before { Routemaster::Config.drain_redis.flushdb }
10
+ before { Routemaster::Config.cache_redis.redis.flushdb }
11
+ before { Routemaster::Config.drain_redis.redis.flushdb }
12
12
  end
13
13
  end
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routemaster-drain
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: net-http-persistent
42
+ name: typhoeus
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "<"
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3'
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "<"
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3'
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: thread
112
+ name: concurrent-ruby
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -129,10 +129,12 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".codeclimate.yml"
132
133
  - ".env.test"
133
134
  - ".gitignore"
134
135
  - ".gitmodules"
135
136
  - ".rspec"
137
+ - ".rubocop.yml"
136
138
  - ".ruby-version"
137
139
  - ".travis.yml"
138
140
  - ".yardopts"
@@ -144,14 +146,17 @@ files:
144
146
  - LICENSE.txt
145
147
  - README.md
146
148
  - Rakefile
149
+ - appraise
147
150
  - gemfiles/rails_3.gemfile
148
151
  - gemfiles/rails_3.gemfile.lock
149
152
  - gemfiles/rails_4.gemfile
150
153
  - gemfiles/rails_4.gemfile.lock
151
154
  - gemfiles/rails_5.gemfile
152
155
  - gemfiles/rails_5.gemfile.lock
156
+ - lib/core_ext/forwardable.rb
153
157
  - lib/routemaster/api_client.rb
154
158
  - lib/routemaster/cache.rb
159
+ - lib/routemaster/cache_key.rb
155
160
  - lib/routemaster/config.rb
156
161
  - lib/routemaster/dirty/filter.rb
157
162
  - lib/routemaster/dirty/map.rb
@@ -162,6 +167,8 @@ files:
162
167
  - lib/routemaster/drain/mapping.rb
163
168
  - lib/routemaster/drain/terminator.rb
164
169
  - lib/routemaster/errors.rb
170
+ - lib/routemaster/event_index.rb
171
+ - lib/routemaster/jobs.rb
165
172
  - lib/routemaster/jobs/backends/resque.rb
166
173
  - lib/routemaster/jobs/backends/sidekiq.rb
167
174
  - lib/routemaster/jobs/cache.rb
@@ -177,9 +184,11 @@ files:
177
184
  - lib/routemaster/middleware/parse.rb
178
185
  - lib/routemaster/middleware/response_caching.rb
179
186
  - lib/routemaster/middleware/root_post_only.rb
187
+ - lib/routemaster/null_logger.rb
180
188
  - lib/routemaster/redis_broker.rb
181
189
  - lib/routemaster/resources/rest_resource.rb
182
190
  - lib/routemaster/responses/future_response.rb
191
+ - lib/routemaster/responses/hateoas_enumerable_response.rb
183
192
  - lib/routemaster/responses/hateoas_response.rb
184
193
  - routemaster-drain.gemspec
185
194
  - spec/routemaster/api_client_spec.rb
@@ -206,14 +215,17 @@ files:
206
215
  - spec/routemaster/middleware/root_post_only_spec.rb
207
216
  - spec/routemaster/redis_broker_spec.rb
208
217
  - spec/routemaster/resources/rest_resource_spec.rb
218
+ - spec/routemaster/responses/future_response_spec.rb
219
+ - spec/routemaster/responses/hateoas_enumerable_response_spec.rb
209
220
  - spec/routemaster/responses/hateoas_response_spec.rb
210
221
  - spec/spec_helper.rb
222
+ - spec/support/breakpoint_class.rb
211
223
  - spec/support/events.rb
212
224
  - spec/support/rack_test.rb
225
+ - spec/support/server.rb
213
226
  - spec/support/uses_dotenv.rb
214
227
  - spec/support/uses_redis.rb
215
228
  - spec/support/uses_webmock.rb
216
- - test.rb
217
229
  homepage: http://github.com/HouseTrip/routemaster_drain
218
230
  licenses:
219
231
  - MIT
@@ -234,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
246
  version: '0'
235
247
  requirements: []
236
248
  rubyforge_project:
237
- rubygems_version: 2.5.1
249
+ rubygems_version: 2.6.8
238
250
  signing_key:
239
251
  specification_version: 4
240
252
  summary: Event receiver for the Routemaster bus
@@ -263,10 +275,14 @@ test_files:
263
275
  - spec/routemaster/middleware/root_post_only_spec.rb
264
276
  - spec/routemaster/redis_broker_spec.rb
265
277
  - spec/routemaster/resources/rest_resource_spec.rb
278
+ - spec/routemaster/responses/future_response_spec.rb
279
+ - spec/routemaster/responses/hateoas_enumerable_response_spec.rb
266
280
  - spec/routemaster/responses/hateoas_response_spec.rb
267
281
  - spec/spec_helper.rb
282
+ - spec/support/breakpoint_class.rb
268
283
  - spec/support/events.rb
269
284
  - spec/support/rack_test.rb
285
+ - spec/support/server.rb
270
286
  - spec/support/uses_dotenv.rb
271
287
  - spec/support/uses_redis.rb
272
288
  - spec/support/uses_webmock.rb
data/test.rb DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
-
4
- require 'rubygems'
5
- require 'bundler/setup'
6
- require 'dotenv'
7
- require 'pry'
8
- require 'routemaster/cache'
9
- # require 'routemaster/client/openssl'
10
-
11
-
12
- Dotenv.load
13
- Routemaster::Config.cache_redis.flushdb
14
- $url = 'https://blackhole.dev/api/widgets/123'
15
- $cache = Routemaster::Cache.new
16
-
17
- binding.pry