message_bus 2.0.8 → 2.0.9

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.

Potentially problematic release.


This version of message_bus might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb7e54feea7687a8c288c301ba14dd8a15743bb0
4
- data.tar.gz: 8c94b50ad0abf8bfc4b4cacbdf166dc05efbd822
3
+ metadata.gz: 558fcebb3ac3abe9031039c73f996264da91cf27
4
+ data.tar.gz: f1bc3ef44e127a51952a8f27acf33e0980494a51
5
5
  SHA512:
6
- metadata.gz: 70e3e09a7149564daab5a4db4ed793ceb22dca73bf3a7513287d9c3bf8c77521de7cf1b1c4f667c2186cb508ae9c4e86ac54e293ff951c97f526881006030917
7
- data.tar.gz: 9d0f71aa3609a3636337922ce2cf400c80c5a99baaae5f24d079ecc72448cb076be30fe832368bfc84dc2d5711164fa5a6cc5a309afa5e118bd47764bc36fbe8
6
+ metadata.gz: 64fde0c29746bd402f04c9502aa304b700ea8b27eff505a9385f88de11f054cdb84f12f006478b6efcc4de9b897dbaf2c0d4e0ac485497ce32fa7e47ead9caae
7
+ data.tar.gz: 3f8dd7191ef89cdf0ec82211098a5a310382d91525c9ea39006d326f13e2e61b5b59dac4ddc6b77b60e1fd74973d00d0d7a12eb9913c772abc2b3cc4091dd740
data/.travis.yml CHANGED
@@ -1,10 +1,9 @@
1
1
  before_install: gem install bundler
2
2
  language: ruby
3
3
  rvm:
4
- - 2.0.0
5
- - 2.1.8
6
- - 2.2.4
7
- - 2.3.0
4
+ - 2.2
5
+ - 2.3
6
+ - 2.4
8
7
  gemfile:
9
8
  - Gemfile
10
9
  addons:
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 24-11-2017
2
+
3
+ - Version 2.0.9
4
+
5
+ - PERF: faster serialization of messages
6
+ - FEATURE: on backend flush web clients will resume and continue to get all new messages
7
+
1
8
  06-10-2017
2
9
 
3
10
  - Version 2.0.8
data/Gemfile CHANGED
@@ -10,8 +10,7 @@ group :test do
10
10
  gem 'thin'
11
11
  gem 'rack-test', require: 'rack/test'
12
12
  gem 'jasmine'
13
- gem 'redis'
14
13
  end
15
14
 
16
- gem 'redis', '3.3.5', platform: :mri_20
17
- gem 'rack', '1.6.4', platform: :mri_20
15
+ gem 'redis'
16
+ gem 'rack'
data/README.md CHANGED
@@ -24,7 +24,10 @@ If you are looking to contribute to this project here are some ideas
24
24
  - Improve general documentation (Add examples, refine existing examples)
25
25
  - Make MessageBus a nice website
26
26
  - Add optional transports for websocket and shared web workers
27
- - Add `# frozen_string_literal: true` to all non test files and adjust code to allow for it.
27
+
28
+ ## Ruby version support
29
+
30
+ MessageBus only support officially supported versions of Ruby, as of 11-2017 this means we only support Ruby version 2.2 and up.
28
31
 
29
32
  ## Can you handle concurrent requests?
30
33
 
@@ -216,7 +219,7 @@ backgroundCallbackInterval|60000|Interval to poll when long polling is disabled
216
219
  maxPollInterval|180000|If request to the server start failing, MessageBus will backoff, this is the upper limit of the backoff.
217
220
  alwaysLongPoll|false|For debugging you may want to disable the "is browser in background" check and always long-poll
218
221
  baseUrl|/|If message bus is mounted in a subdirectory of different domain, you may configure it to perform requests there
219
- ajax|$.ajax or XMLHttpRequest|MessageBus will first attempt to use jQuery and then fallback to a plain XMLHttpRequest version that's contained in the `messsage-bus-ajax.js` file. `messsage-bus-ajax.js` must be loaded after `messsage-bus.js` for it to be used.
222
+ ajax|$.ajax or XMLHttpRequest|MessageBus will first attempt to use jQuery and then fallback to a plain XMLHttpRequest version that's contained in the `message-bus-ajax.js` file. `message-bus-ajax.js` must be loaded after `message-bus.js` for it to be used.
220
223
  headers|{}|Extra headers to be include with request. Properties and values of object must be valid values for HTTP Headers, i.e. no spaces and control characters.
221
224
  **API**:
222
225
 
data/Rakefile CHANGED
@@ -10,7 +10,20 @@ load 'jasmine/tasks/jasmine.rake'
10
10
 
11
11
  Bundler.require(:default, :test)
12
12
 
13
- task :default => [:spec]
13
+ task default: :spec
14
+
15
+ module CustomBuild
16
+ def build_gem
17
+ `cp assets/message-bus* vendor/assets/javascripts`
18
+ super
19
+ end
20
+ end
21
+
22
+ module Bundler
23
+ class GemHelper
24
+ prepend CustomBuild
25
+ end
26
+ end
14
27
 
15
28
  run_spec = proc do |backend|
16
29
  begin
@@ -21,9 +34,9 @@ run_spec = proc do |backend|
21
34
  end
22
35
  end
23
36
 
24
- task :spec => [:spec_redis, :spec_postgres, :spec_memory, :spec_client_js]
37
+ task spec: [:spec_redis, :spec_postgres, :spec_memory, :spec_client_js]
25
38
 
26
- task :spec_client_js => 'jasmine:ci'
39
+ task spec_client_js: 'jasmine:ci'
27
40
 
28
41
  task :spec_redis do
29
42
  run_spec.call('redis')
@@ -124,12 +124,18 @@ class MessageBus::Client
124
124
  next if v.to_i < 0
125
125
  messages = @bus.backlog(k, v, site_id)
126
126
 
127
- messages.each do |msg|
128
- if allowed?(msg)
129
- r << msg
130
- else
131
- new_message_ids ||= {}
132
- new_message_ids[k] = msg.message_id
127
+ if messages.length == 0
128
+ if v.to_i > @bus.last_id(k, site_id)
129
+ @subscriptions[k] = -1
130
+ end
131
+ else
132
+ messages.each do |msg|
133
+ if allowed?(msg)
134
+ r << msg
135
+ else
136
+ new_message_ids ||= {}
137
+ new_message_ids[k] = msg.message_id
138
+ end
133
139
  end
134
140
  end
135
141
  end
@@ -9,8 +9,13 @@ class MessageBus::Message < Struct.new(:global_id, :message_id, :channel , :data
9
9
  s2 = encoded.index("|", s1 + 1)
10
10
  s3 = encoded.index("|", s2 + 1)
11
11
 
12
- MessageBus::Message.new(encoded[0..s1].to_i, encoded[(s1 + 1)..s2].to_i,
13
- encoded[(s2 + 1)..(s3 - 1)].gsub("$$123$$", "|"), encoded[(s3 + 1)..-1])
12
+ global_id = encoded[0, s1 + 1].to_i
13
+ message_id = encoded[(s1 + 1), (s2 - s1 - 1)].to_i
14
+ channel = encoded[(s2 + 1), (s3 - s2 - 1)]
15
+ channel.gsub!("$$123$$", "|")
16
+ data = encoded[(s3 + 1), encoded.size]
17
+
18
+ MessageBus::Message.new(global_id, message_id, channel, data)
14
19
  end
15
20
 
16
21
  # only tricky thing to encode is pipes in a channel name ... do a straight replace
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MessageBus
3
- VERSION = "2.0.8"
3
+ VERSION = "2.0.9"
4
4
  end
data/message_bus.gemspec CHANGED
@@ -9,14 +9,14 @@ Gem::Specification.new do |gem|
9
9
  gem.summary = %q{}
10
10
  gem.homepage = "https://github.com/SamSaffron/message_bus"
11
11
  gem.license = "MIT"
12
-
13
- gem.files = `git ls-files`.split($\)
12
+ gem.files = `git ls-files`.split($\) +
13
+ ["vendor/assets/javascripts/message-bus.js", "vendor/assets/javascripts/message-bus-ajax.js"]
14
14
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
  gem.name = "message_bus"
17
17
  gem.require_paths = ["lib"]
18
18
  gem.version = MessageBus::VERSION
19
- gem.required_ruby_version = ">= 1.9.3"
19
+ gem.required_ruby_version = ">= 2.2.0"
20
20
  gem.add_runtime_dependency 'rack', '>= 1.1.3'
21
21
  gem.add_development_dependency 'redis'
22
22
  gem.add_development_dependency 'pg'
@@ -2,220 +2,252 @@ require_relative '../../../spec_helper'
2
2
  require 'message_bus'
3
3
 
4
4
  if MESSAGE_BUS_CONFIG[:backend] == :redis
5
- describe PUB_SUB_CLASS do
5
+ describe PUB_SUB_CLASS do
6
6
 
7
- def new_test_bus
8
- PUB_SUB_CLASS.new(MESSAGE_BUS_CONFIG.merge(:db => 10))
9
- end
7
+ def new_test_bus
8
+ PUB_SUB_CLASS.new(MESSAGE_BUS_CONFIG.merge(db: 10))
9
+ end
10
10
 
11
- before do
12
- @bus = new_test_bus
13
- @bus.reset!
14
- end
11
+ before do
12
+ @bus = new_test_bus
13
+ @bus.reset!
14
+ end
15
15
 
16
- describe "readonly" do
16
+ describe "readonly" do
17
17
 
18
- after do
19
- @bus.pub_redis.slaveof "no", "one"
20
- end
18
+ after do
19
+ @bus.pub_redis.slaveof "no", "one"
20
+ end
21
+
22
+ it "should be able to store messages in memory for a period while in read only" do
21
23
 
22
- it "should be able to store messages in memory for a period while in read only" do
24
+ skip "This spec changes redis behavior that in turn means other specs run slow"
23
25
 
24
- skip "This spec changes redis behavior that in turn means other specs run slow"
26
+ @bus.pub_redis.slaveof "127.0.0.80", "666"
27
+ @bus.max_in_memory_publish_backlog = 2
25
28
 
26
- @bus.pub_redis.slaveof "127.0.0.80", "666"
27
- @bus.max_in_memory_publish_backlog = 2
29
+ current_threads = Thread.list
30
+ current_threads_length = current_threads.count
28
31
 
29
- current_threads = Thread.list
30
- current_threads_length = current_threads.count
32
+ 3.times do
33
+ result = @bus.publish "/foo", "bar"
34
+ assert_nil result
35
+ Thread.list.length.must_equal (current_threads_length + 1)
36
+ end
31
37
 
32
- 3.times do
33
- result = @bus.publish "/foo", "bar"
34
- assert_nil result
35
- Thread.list.length.must_equal (current_threads_length + 1)
38
+ @bus.pub_redis.slaveof "no", "one"
39
+ sleep 0.01
40
+
41
+ (Thread.list - current_threads).each(&:join)
42
+ Thread.list.length.must_equal current_threads_length
43
+
44
+ @bus.backlog("/foo", 0).map(&:data).must_equal ["bar", "bar"]
36
45
  end
46
+ end
37
47
 
38
- @bus.pub_redis.slaveof "no", "one"
39
- sleep 0.01
48
+ it "can set backlog age" do
49
+ @bus.max_backlog_age = 100
50
+ @bus.publish "/foo", "bar"
51
+ @bus.pub_redis.ttl(@bus.backlog_key("/foo")).must_be :<=, 100
52
+ @bus.pub_redis.ttl(@bus.backlog_key("/foo")).must_be :>, 0
53
+ end
40
54
 
41
- (Thread.list - current_threads).each(&:join)
42
- Thread.list.length.must_equal current_threads_length
55
+ it "should be able to access the backlog" do
56
+ @bus.publish "/foo", "bar"
57
+ @bus.publish "/foo", "baz"
43
58
 
44
- @bus.backlog("/foo", 0).map(&:data).must_equal ["bar","bar"]
59
+ @bus.backlog("/foo", 0).to_a.must_equal [
60
+ MessageBus::Message.new(1, 1, '/foo', 'bar'),
61
+ MessageBus::Message.new(2, 2, '/foo', 'baz')
62
+ ]
45
63
  end
46
- end
47
64
 
48
- it "can set backlog age" do
49
- @bus.max_backlog_age = 100
50
- @bus.publish "/foo", "bar"
51
- @bus.pub_redis.ttl(@bus.backlog_key("/foo")).must_be :<=, 100
52
- @bus.pub_redis.ttl(@bus.backlog_key("/foo")).must_be :>, 0
53
- end
65
+ it "should initialize with max_backlog_size" do
66
+ PUB_SUB_CLASS.new({}, 2000).max_backlog_size.must_equal 2000
67
+ end
54
68
 
55
- it "should be able to access the backlog" do
56
- @bus.publish "/foo", "bar"
57
- @bus.publish "/foo", "baz"
69
+ it "should truncate channels correctly" do
70
+ @bus.max_backlog_size = 2
71
+ 4.times do |t|
72
+ @bus.publish "/foo", t.to_s
73
+ end
58
74
 
59
- @bus.backlog("/foo", 0).to_a.must_equal [
60
- MessageBus::Message.new(1,1,'/foo','bar'),
61
- MessageBus::Message.new(2,2,'/foo','baz')
62
- ]
63
- end
75
+ @bus.backlog("/foo").to_a.must_equal [
76
+ MessageBus::Message.new(3, 3, '/foo', '2'),
77
+ MessageBus::Message.new(4, 4, '/foo', '3'),
78
+ ]
79
+ end
64
80
 
65
- it "should initialize with max_backlog_size" do
66
- PUB_SUB_CLASS.new({},2000).max_backlog_size.must_equal 2000
67
- end
81
+ it "should truncate global backlog correctly" do
82
+ @bus.max_global_backlog_size = 2
83
+ @bus.publish "/foo", "1"
84
+ @bus.publish "/bar", "2"
85
+ @bus.publish "/baz", "3"
68
86
 
69
- it "should truncate channels correctly" do
70
- @bus.max_backlog_size = 2
71
- 4.times do |t|
72
- @bus.publish "/foo", t.to_s
87
+ @bus.global_backlog.length.must_equal 2
73
88
  end
74
89
 
75
- @bus.backlog("/foo").to_a.must_equal [
76
- MessageBus::Message.new(3,3,'/foo','2'),
77
- MessageBus::Message.new(4,4,'/foo','3'),
78
- ]
79
- end
90
+ it "should be able to grab a message by id" do
91
+ id1 = @bus.publish "/foo", "bar"
92
+ id2 = @bus.publish "/foo", "baz"
93
+ @bus.get_message("/foo", id2).must_equal MessageBus::Message.new(2, 2, "/foo", "baz")
94
+ @bus.get_message("/foo", id1).must_equal MessageBus::Message.new(1, 1, "/foo", "bar")
95
+ end
80
96
 
81
- it "should truncate global backlog correctly" do
82
- @bus.max_global_backlog_size = 2
83
- @bus.publish "/foo", "1"
84
- @bus.publish "/bar", "2"
85
- @bus.publish "/baz", "3"
97
+ it "should be able to access the global backlog" do
98
+ @bus.publish "/foo", "bar"
99
+ @bus.publish "/hello", "world"
100
+ @bus.publish "/foo", "baz"
101
+ @bus.publish "/hello", "planet"
102
+
103
+ @bus.global_backlog.to_a.must_equal [
104
+ MessageBus::Message.new(1, 1, "/foo", "bar"),
105
+ MessageBus::Message.new(2, 1, "/hello", "world"),
106
+ MessageBus::Message.new(3, 2, "/foo", "baz"),
107
+ MessageBus::Message.new(4, 2, "/hello", "planet")
108
+ ]
109
+ end
86
110
 
87
- @bus.global_backlog.length.must_equal 2
88
- end
111
+ it "should correctly omit dropped messages from the global backlog" do
112
+ @bus.max_backlog_size = 1
113
+ @bus.publish "/foo", "a"
114
+ @bus.publish "/foo", "b"
115
+ @bus.publish "/bar", "a"
116
+ @bus.publish "/bar", "b"
117
+
118
+ @bus.global_backlog.to_a.must_equal [
119
+ MessageBus::Message.new(2, 2, "/foo", "b"),
120
+ MessageBus::Message.new(4, 2, "/bar", "b")
121
+ ]
122
+ end
89
123
 
90
- it "should be able to grab a message by id" do
91
- id1 = @bus.publish "/foo", "bar"
92
- id2 = @bus.publish "/foo", "baz"
93
- @bus.get_message("/foo", id2).must_equal MessageBus::Message.new(2, 2, "/foo", "baz")
94
- @bus.get_message("/foo", id1).must_equal MessageBus::Message.new(1, 1, "/foo", "bar")
95
- end
124
+ it "should have the correct number of messages for multi threaded access" do
125
+ threads = []
126
+ 4.times do
127
+ threads << Thread.new do
128
+ bus = new_test_bus
129
+ 25.times {
130
+ bus.publish "/foo", "."
131
+ }
132
+ end
133
+ end
96
134
 
97
- it "should be able to access the global backlog" do
98
- @bus.publish "/foo", "bar"
99
- @bus.publish "/hello", "world"
100
- @bus.publish "/foo", "baz"
101
- @bus.publish "/hello", "planet"
102
-
103
- @bus.global_backlog.to_a.must_equal [
104
- MessageBus::Message.new(1, 1, "/foo", "bar"),
105
- MessageBus::Message.new(2, 1, "/hello", "world"),
106
- MessageBus::Message.new(3, 2, "/foo", "baz"),
107
- MessageBus::Message.new(4, 2, "/hello", "planet")
108
- ]
109
- end
135
+ threads.each(&:join)
136
+ @bus.backlog("/foo").length == 100
137
+ end
110
138
 
111
- it "should correctly omit dropped messages from the global backlog" do
112
- @bus.max_backlog_size = 1
113
- @bus.publish "/foo", "a"
114
- @bus.publish "/foo", "b"
115
- @bus.publish "/bar", "a"
116
- @bus.publish "/bar", "b"
117
-
118
- @bus.global_backlog.to_a.must_equal [
119
- MessageBus::Message.new(2, 2, "/foo", "b"),
120
- MessageBus::Message.new(4, 2, "/bar", "b")
121
- ]
122
- end
139
+ it "should be able to subscribe globally with recovery" do
140
+ @bus.publish("/foo", "1")
141
+ @bus.publish("/bar", "2")
142
+ got = []
123
143
 
124
- it "should have the correct number of messages for multi threaded access" do
125
- threads = []
126
- 4.times do
127
- threads << Thread.new do
128
- bus = new_test_bus
129
- 25.times {
130
- bus.publish "/foo", "."
131
- }
144
+ t = Thread.new do
145
+ new_test_bus.global_subscribe(0) do |msg|
146
+ got << msg
147
+ end
132
148
  end
149
+
150
+ @bus.publish("/bar", "3")
151
+
152
+ wait_for(100) do
153
+ got.length == 3
154
+ end
155
+
156
+ t.kill
157
+
158
+ got.length.must_equal 3
159
+ got.map { |m| m.data }.must_equal ["1", "2", "3"]
133
160
  end
134
161
 
135
- threads.each{|t| t.join}
136
- @bus.backlog("/foo").length == 100
137
- end
162
+ it "should be able to encode and decode messages properly" do
163
+ m = MessageBus::Message.new 1, 2, '||', '||'
164
+ MessageBus::Message.decode(m.encode).must_equal m
165
+ end
138
166
 
139
- it "should be able to subscribe globally with recovery" do
140
- @bus.publish("/foo", "1")
141
- @bus.publish("/bar", "2")
142
- got = []
167
+ it "should handle subscribe on single channel, with recovery" do
168
+ @bus.publish("/foo", "1")
169
+ @bus.publish("/bar", "2")
170
+ got = []
143
171
 
144
- t = Thread.new do
145
- new_test_bus.global_subscribe(0) do |msg|
146
- got << msg
172
+ t = Thread.new do
173
+ new_test_bus.subscribe("/foo", 0) do |msg|
174
+ got << msg
175
+ end
176
+ end
177
+
178
+ @bus.publish("/foo", "3")
179
+
180
+ wait_for(100) do
181
+ got.length == 2
147
182
  end
148
- end
149
183
 
150
- @bus.publish("/bar", "3")
184
+ t.kill
151
185
 
152
- wait_for(100) do
153
- got.length == 3
186
+ got.map { |m| m.data }.must_equal ["1", "3"]
154
187
  end
155
188
 
156
- t.kill
189
+ it "should not get backlog if subscribe is called without params" do
190
+ @bus.publish("/foo", "1")
191
+ got = []
157
192
 
158
- got.length.must_equal 3
159
- got.map{|m| m.data}.must_equal ["1","2","3"]
160
- end
193
+ t = Thread.new do
194
+ new_test_bus.subscribe("/foo") do |msg|
195
+ got << msg
196
+ end
197
+ end
161
198
 
162
- it "should be able to encode and decode messages properly" do
163
- m = MessageBus::Message.new 1,2,'||','||'
164
- MessageBus::Message.decode(m.encode).must_equal m
165
- end
199
+ # sleep 50ms to allow the bus to correctly subscribe,
200
+ # I thought about adding a subscribed callback, but outside of testing it matters less
201
+ sleep 0.05
166
202
 
167
- it "should handle subscribe on single channel, with recovery" do
168
- @bus.publish("/foo", "1")
169
- @bus.publish("/bar", "2")
170
- got = []
203
+ @bus.publish("/foo", "2")
171
204
 
172
- t = Thread.new do
173
- new_test_bus.subscribe("/foo",0) do |msg|
174
- got << msg
205
+ wait_for(100) do
206
+ got.length == 1
175
207
  end
176
- end
177
208
 
178
- @bus.publish("/foo", "3")
209
+ t.kill
179
210
 
180
- wait_for(100) do
181
- got.length == 2
211
+ got.map { |m| m.data }.must_equal ["2"]
182
212
  end
183
213
 
184
- t.kill
214
+ it "should cope with a redis reset cleanly" do
185
215
 
186
- got.map{|m| m.data}.must_equal ["1","3"]
187
- end
216
+ @bus.publish("/foo", "1")
217
+ got = []
218
+
219
+ t = Thread.new do
220
+ new_test_bus.subscribe("/foo") do |msg|
221
+ got << msg
222
+ end
223
+ end
224
+
225
+ # sleep 50ms to allow the bus to correctly subscribe,
226
+ # I thought about adding a subscribed callback, but outside of testing it matters less
227
+ sleep 0.05
228
+
229
+ @bus.publish("/foo", "2")
230
+
231
+ @bus.pub_redis.flushdb
188
232
 
189
- it "should not get backlog if subscribe is called without params" do
190
- @bus.publish("/foo", "1")
191
- got = []
233
+ @bus.publish("/foo", "3")
192
234
 
193
- t = Thread.new do
194
- new_test_bus.subscribe("/foo") do |msg|
195
- got << msg
235
+ wait_for(100) do
236
+ got.length == 2
196
237
  end
197
- end
198
238
 
199
- # sleep 50ms to allow the bus to correctly subscribe,
200
- # I thought about adding a subscribed callback, but outside of testing it matters less
201
- sleep 0.05
239
+ t.kill
202
240
 
203
- @bus.publish("/foo", "2")
241
+ got.map { |m| m.data }.must_equal ["2", "3"]
242
+ got[1].global_id.must_equal 1
204
243
 
205
- wait_for(100) do
206
- got.length == 1
207
244
  end
208
245
 
209
- t.kill
210
-
211
- got.map{|m| m.data}.must_equal ["2"]
212
- end
246
+ it "should allow us to get last id on a channel" do
247
+ @bus.last_id("/foo").must_equal 0
248
+ @bus.publish("/foo", "1")
249
+ @bus.last_id("/foo").must_equal 1
250
+ end
213
251
 
214
- it "should allow us to get last id on a channel" do
215
- @bus.last_id("/foo").must_equal 0
216
- @bus.publish("/foo", "1")
217
- @bus.last_id("/foo").must_equal 1
218
252
  end
219
-
220
- end
221
253
  end
@@ -164,6 +164,26 @@ describe MessageBus::Rack::Middleware do
164
164
  last_response.ok?.must_equal true
165
165
  end
166
166
 
167
+ # this means we recover from redis reset
168
+ it "should understand that larger than position is the same as -1" do
169
+ @bus.publish('/foo', 'bar')
170
+ @bus.publish('/baz', 'test')
171
+ @bus.publish('/boom', 'bang')
172
+
173
+ post "/message-bus/ABCD",
174
+ '/foo' => 1_000_000,
175
+ '/baz' => @bus.last_id('/baz') + 1,
176
+ '/boom' => 1_000_000
177
+
178
+ last_response.ok?.must_equal true
179
+ parsed = JSON.parse(last_response.body)
180
+
181
+ parsed.length.must_equal 1
182
+ parsed[0]["channel"].must_equal "/__status"
183
+ parsed[0]["data"]["/foo"].must_equal @bus.last_id("/foo")
184
+ parsed[0]["data"]["/boom"].must_equal @bus.last_id("/boom")
185
+ end
186
+
167
187
  it "should correctly understand that -1 means stuff from now onwards" do
168
188
 
169
189
  # even if allow chunked
@@ -0,0 +1,2 @@
1
+ message-bus.js
2
+ message-bus-ajax.js
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-06 00:00:00.000000000 Z
11
+ date: 2017-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redis
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pg
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: A message bus for rack
@@ -59,9 +59,9 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
63
- - .rubocop.yml
64
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".rubocop.yml"
64
+ - ".travis.yml"
65
65
  - CHANGELOG
66
66
  - Gemfile
67
67
  - Guardfile
@@ -119,6 +119,7 @@ files:
119
119
  - spec/lib/message_bus/timer_thread_spec.rb
120
120
  - spec/lib/message_bus_spec.rb
121
121
  - spec/spec_helper.rb
122
+ - vendor/assets/javascripts/.gitignore
122
123
  - vendor/assets/javascripts/message-bus-ajax.js
123
124
  - vendor/assets/javascripts/message-bus.js
124
125
  homepage: https://github.com/SamSaffron/message_bus
@@ -131,17 +132,17 @@ require_paths:
131
132
  - lib
132
133
  required_ruby_version: !ruby/object:Gem::Requirement
133
134
  requirements:
134
- - - '>='
135
+ - - ">="
135
136
  - !ruby/object:Gem::Version
136
- version: 1.9.3
137
+ version: 2.2.0
137
138
  required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  requirements:
139
- - - '>='
140
+ - - ">="
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  requirements: []
143
144
  rubyforge_project:
144
- rubygems_version: 2.0.14
145
+ rubygems_version: 2.6.13
145
146
  signing_key:
146
147
  specification_version: 4
147
148
  summary: ''