pubnub 4.2.0 → 4.2.1
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.
- checksums.yaml +4 -4
- data/.pubnub.yml +8 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/lib/events/create_space.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/create_user.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/delete_space.yml +38 -0
- data/fixtures/vcr_cassettes/lib/events/delete_user.yml +38 -0
- data/fixtures/vcr_cassettes/lib/events/get_members.yml +38 -0
- data/fixtures/vcr_cassettes/lib/events/get_space.yml +38 -0
- data/fixtures/vcr_cassettes/lib/events/get_space_memberships.yml +38 -0
- data/fixtures/vcr_cassettes/lib/events/get_spaces.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/get_user.yml +38 -0
- data/fixtures/vcr_cassettes/lib/events/manage_members_add.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/manage_members_remove.yml +83 -0
- data/fixtures/vcr_cassettes/lib/events/manage_memberships_add.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/manage_memberships_remove.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-member-remove-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-space-delete-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-user-delete-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/subscribe-user-update-async.yml +77 -0
- data/fixtures/vcr_cassettes/lib/events/update_space.yml +40 -0
- data/fixtures/vcr_cassettes/lib/events/update_user.yml +40 -0
- data/lib/pubnub/subscribe_callback.rb +4 -1
- data/lib/pubnub/subscribe_event/formatter.rb +33 -0
- data/lib/pubnub/subscriber.rb +6 -0
- data/lib/pubnub/version.rb +1 -1
- data/spec/lib/events/subscribe_spec.rb +188 -0
- metadata +25 -2
data/lib/pubnub/subscriber.rb
CHANGED
|
@@ -75,6 +75,12 @@ module Pubnub
|
|
|
75
75
|
secure_call callbacks.callbacks[:signal], envelope
|
|
76
76
|
when Pubnub::Constants::OPERATION_PRESENCE
|
|
77
77
|
secure_call callbacks.callbacks[:presence], envelope
|
|
78
|
+
when Pubnub::Constants::OPERATION_CREATE_USER, Pubnub::Constants::OPERATION_UPDATE_USER, Pubnub::Constants::OPERATION_DELETE_USER
|
|
79
|
+
secure_call callbacks.callbacks[:user], envelope
|
|
80
|
+
when Pubnub::Constants::OPERATION_CREATE_SPACE, Pubnub::Constants::OPERATION_UPDATE_SPACE, Pubnub::Constants::OPERATION_DELETE_SPACE
|
|
81
|
+
secure_call callbacks.callbacks[:space], envelope
|
|
82
|
+
when Pubnub::Constants::OPERATION_MANAGE_MEMBERS, Pubnub::Constants::OPERATION_MANAGE_MEMBERSHIPS
|
|
83
|
+
secure_call callbacks.callbacks[:membership], envelope
|
|
78
84
|
else
|
|
79
85
|
secure_call callbacks.callbacks[:status], envelope
|
|
80
86
|
end
|
data/lib/pubnub/version.rb
CHANGED
|
@@ -12,11 +12,19 @@ describe Pubnub::Subscribe do
|
|
|
12
12
|
before :each do
|
|
13
13
|
@messages = []
|
|
14
14
|
@statuses = []
|
|
15
|
+
@signals = []
|
|
16
|
+
@user_events = []
|
|
17
|
+
@space_events = []
|
|
18
|
+
@membership_events = []
|
|
15
19
|
|
|
16
20
|
@callbacks = Pubnub::SubscribeCallback.new(
|
|
17
21
|
message: -> (envelope) { @messages << envelope },
|
|
18
22
|
presence: -> (_envelope) { },
|
|
19
23
|
status: -> (envelope) { @statuses << envelope },
|
|
24
|
+
signal: -> (envelope) { @signals << envelope },
|
|
25
|
+
user: -> (envelope) { @user_events << envelope },
|
|
26
|
+
space: -> (envelope) { @space_events << envelope },
|
|
27
|
+
membership: -> (envelope) { @membership_events << envelope }
|
|
20
28
|
)
|
|
21
29
|
end
|
|
22
30
|
|
|
@@ -98,6 +106,102 @@ describe Pubnub::Subscribe do
|
|
|
98
106
|
end
|
|
99
107
|
end
|
|
100
108
|
end
|
|
109
|
+
|
|
110
|
+
it "user update works" do
|
|
111
|
+
VCR.use_cassette("lib/events/subscribe-user-update-async", record: :once) do
|
|
112
|
+
@pubnub = Pubnub::Client.new(
|
|
113
|
+
subscribe_key: "sub-a-mock-key",
|
|
114
|
+
publish_key: "pub-a-mock-key",
|
|
115
|
+
auth_key: "ruby-test-auth",
|
|
116
|
+
uuid: "ruby-test-uuid"
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
@pubnub.add_listener(callback: @callbacks)
|
|
120
|
+
|
|
121
|
+
@pubnub.subscribe(channel: :user_mg3)
|
|
122
|
+
|
|
123
|
+
eventually do
|
|
124
|
+
envelope = @user_events.first
|
|
125
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
126
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
127
|
+
expect(envelope.result[:data][:message]['event']).to eq 'update'
|
|
128
|
+
expect(envelope.result[:data][:message]['type']).to eq 'user'
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "space update works" do
|
|
134
|
+
VCR.use_cassette("lib/events/subscribe-space-update-async", record: :once) do
|
|
135
|
+
@pubnub = Pubnub::Client.new(
|
|
136
|
+
subscribe_key: "sub-a-mock-key",
|
|
137
|
+
publish_key: "pub-a-mock-key",
|
|
138
|
+
auth_key: "ruby-test-auth",
|
|
139
|
+
uuid: "ruby-test-uuid"
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
@pubnub.add_listener(callback: @callbacks)
|
|
143
|
+
|
|
144
|
+
@pubnub.subscribe(channel: :rb_space_3)
|
|
145
|
+
|
|
146
|
+
eventually do
|
|
147
|
+
envelope = @space_events.first
|
|
148
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
149
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
150
|
+
expect(envelope.result[:data][:message]['event']).to eq 'update'
|
|
151
|
+
expect(envelope.result[:data][:message]['type']).to eq 'space'
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it "member add works" do
|
|
157
|
+
VCR.use_cassette("lib/events/subscribe-member-add-async", record: :once) do
|
|
158
|
+
@pubnub = Pubnub::Client.new(
|
|
159
|
+
subscribe_key: "sub-a-mock-key",
|
|
160
|
+
publish_key: "pub-a-mock-key",
|
|
161
|
+
auth_key: "ruby-test-auth",
|
|
162
|
+
uuid: "ruby-test-uuid"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
@pubnub.add_listener(callback: @callbacks)
|
|
166
|
+
|
|
167
|
+
@pubnub.subscribe(channel: :rb_space_4)
|
|
168
|
+
|
|
169
|
+
eventually do
|
|
170
|
+
envelope = @membership_events.first
|
|
171
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
172
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
173
|
+
expect(envelope.result[:data][:message]['event']).to eq 'create'
|
|
174
|
+
expect(envelope.result[:data][:message]['type']).to eq 'membership'
|
|
175
|
+
expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4'
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "membership add works" do
|
|
181
|
+
VCR.use_cassette("lib/events/subscribe-membership-add-async", record: :once) do
|
|
182
|
+
@pubnub = Pubnub::Client.new(
|
|
183
|
+
subscribe_key: "sub-a-mock-key",
|
|
184
|
+
publish_key: "pub-a-mock-key",
|
|
185
|
+
auth_key: "ruby-test-auth",
|
|
186
|
+
uuid: "ruby-test-uuid"
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
@pubnub.add_listener(callback: @callbacks)
|
|
190
|
+
|
|
191
|
+
@pubnub.subscribe(channel: :user_mg4)
|
|
192
|
+
|
|
193
|
+
eventually do
|
|
194
|
+
envelope = @membership_events.first
|
|
195
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
196
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
197
|
+
expect(envelope.result[:data][:message]['event']).to eq 'create'
|
|
198
|
+
expect(envelope.result[:data][:message]['type']).to eq 'membership'
|
|
199
|
+
expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4'
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
end
|
|
101
205
|
end
|
|
102
206
|
|
|
103
207
|
context "sync" do
|
|
@@ -153,6 +257,89 @@ describe Pubnub::Subscribe do
|
|
|
153
257
|
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
154
258
|
end
|
|
155
259
|
end
|
|
260
|
+
|
|
261
|
+
it "user delete works" do
|
|
262
|
+
VCR.use_cassette("lib/events/subscribe-user-delete-async", record: :once) do
|
|
263
|
+
@pubnub = Pubnub::Client.new(
|
|
264
|
+
subscribe_key: "sub-a-mock-key",
|
|
265
|
+
publish_key: "pub-a-mock-key",
|
|
266
|
+
auth_key: "ruby-test-auth",
|
|
267
|
+
uuid: "ruby-test-uuid"
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
@pubnub.subscribe(channel: :user_mg3, http_sync: true)
|
|
271
|
+
envelopes = @pubnub.subscribe(channel: :user_mg3, http_sync: true)
|
|
272
|
+
|
|
273
|
+
envelope = envelopes.first
|
|
274
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
275
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
276
|
+
expect(envelope.result[:data][:message]['event']).to eq 'delete'
|
|
277
|
+
expect(envelope.result[:data][:message]['type']).to eq 'user'
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it "space delete works" do
|
|
282
|
+
VCR.use_cassette("lib/events/subscribe-space-delete-async", record: :once) do
|
|
283
|
+
@pubnub = Pubnub::Client.new(
|
|
284
|
+
subscribe_key: "sub-a-mock-key",
|
|
285
|
+
publish_key: "pub-a-mock-key",
|
|
286
|
+
auth_key: "ruby-test-auth",
|
|
287
|
+
uuid: "ruby-test-uuid"
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
@pubnub.subscribe(channel: :rb_space_3, http_sync: true)
|
|
291
|
+
envelopes = @pubnub.subscribe(channel: :rb_space_3, http_sync: true)
|
|
292
|
+
|
|
293
|
+
envelope = envelopes.first
|
|
294
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
295
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
296
|
+
expect(envelope.result[:data][:message]['event']).to eq 'delete'
|
|
297
|
+
expect(envelope.result[:data][:message]['type']).to eq 'space'
|
|
298
|
+
expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_space_3'
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
it "member remove works" do
|
|
303
|
+
VCR.use_cassette("lib/events/subscribe-member-remove-async", record: :once) do
|
|
304
|
+
@pubnub = Pubnub::Client.new(
|
|
305
|
+
subscribe_key: "sub-a-mock-key",
|
|
306
|
+
publish_key: "pub-a-mock-key",
|
|
307
|
+
auth_key: "ruby-test-auth",
|
|
308
|
+
uuid: "ruby-test-uuid"
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
@pubnub.subscribe(channel: :rb_space_4, http_sync: true)
|
|
312
|
+
envelopes = @pubnub.subscribe(channel: :rb_space_4, http_sync: true)
|
|
313
|
+
|
|
314
|
+
envelope = envelopes.first
|
|
315
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
316
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
317
|
+
expect(envelope.result[:data][:message]['event']).to eq 'delete'
|
|
318
|
+
expect(envelope.result[:data][:message]['type']).to eq 'membership'
|
|
319
|
+
expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4'
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
it "membership remove works" do
|
|
324
|
+
VCR.use_cassette("lib/events/subscribe-membership-remove-async", record: :once) do
|
|
325
|
+
@pubnub = Pubnub::Client.new(
|
|
326
|
+
subscribe_key: "sub-a-mock-key",
|
|
327
|
+
publish_key: "pub-a-mock-key",
|
|
328
|
+
auth_key: "ruby-test-auth",
|
|
329
|
+
uuid: "ruby-test-uuid"
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
@pubnub.subscribe(channel: :user_mg4, http_sync: true)
|
|
333
|
+
envelopes = @pubnub.subscribe(channel: :user_mg4, http_sync: true)
|
|
334
|
+
|
|
335
|
+
envelope = envelopes.first
|
|
336
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
|
|
337
|
+
expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
|
|
338
|
+
expect(envelope.result[:data][:message]['event']).to eq 'delete'
|
|
339
|
+
expect(envelope.result[:data][:message]['type']).to eq 'membership'
|
|
340
|
+
expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4'
|
|
341
|
+
end
|
|
342
|
+
|
|
156
343
|
end
|
|
157
344
|
|
|
158
345
|
context "aliases" do
|
|
@@ -212,5 +399,6 @@ describe Pubnub::Subscribe do
|
|
|
212
399
|
end
|
|
213
400
|
end
|
|
214
401
|
end
|
|
402
|
+
|
|
215
403
|
end
|
|
216
404
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubnub
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PubNub
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-10-
|
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -10484,8 +10484,17 @@ files:
|
|
|
10484
10484
|
- fixtures/vcr_cassettes/lib/events/audit-works.yml
|
|
10485
10485
|
- fixtures/vcr_cassettes/lib/events/channel-registration-error.yml
|
|
10486
10486
|
- fixtures/vcr_cassettes/lib/events/channel-registration.yml
|
|
10487
|
+
- fixtures/vcr_cassettes/lib/events/create_space.yml
|
|
10488
|
+
- fixtures/vcr_cassettes/lib/events/create_user.yml
|
|
10487
10489
|
- fixtures/vcr_cassettes/lib/events/delete_messages-error.yml
|
|
10488
10490
|
- fixtures/vcr_cassettes/lib/events/delete_messages.yml
|
|
10491
|
+
- fixtures/vcr_cassettes/lib/events/delete_space.yml
|
|
10492
|
+
- fixtures/vcr_cassettes/lib/events/delete_user.yml
|
|
10493
|
+
- fixtures/vcr_cassettes/lib/events/get_members.yml
|
|
10494
|
+
- fixtures/vcr_cassettes/lib/events/get_space.yml
|
|
10495
|
+
- fixtures/vcr_cassettes/lib/events/get_space_memberships.yml
|
|
10496
|
+
- fixtures/vcr_cassettes/lib/events/get_spaces.yml
|
|
10497
|
+
- fixtures/vcr_cassettes/lib/events/get_user.yml
|
|
10489
10498
|
- fixtures/vcr_cassettes/lib/events/get_users.yml
|
|
10490
10499
|
- fixtures/vcr_cassettes/lib/events/grant-error.yml
|
|
10491
10500
|
- fixtures/vcr_cassettes/lib/events/grant.yml
|
|
@@ -10498,6 +10507,10 @@ files:
|
|
|
10498
10507
|
- fixtures/vcr_cassettes/lib/events/history.yml
|
|
10499
10508
|
- fixtures/vcr_cassettes/lib/events/leave-error.yml
|
|
10500
10509
|
- fixtures/vcr_cassettes/lib/events/leave.yml
|
|
10510
|
+
- fixtures/vcr_cassettes/lib/events/manage_members_add.yml
|
|
10511
|
+
- fixtures/vcr_cassettes/lib/events/manage_members_remove.yml
|
|
10512
|
+
- fixtures/vcr_cassettes/lib/events/manage_memberships_add.yml
|
|
10513
|
+
- fixtures/vcr_cassettes/lib/events/manage_memberships_remove.yml
|
|
10501
10514
|
- fixtures/vcr_cassettes/lib/events/presence-async-error.yml
|
|
10502
10515
|
- fixtures/vcr_cassettes/lib/events/presence-async.yml
|
|
10503
10516
|
- fixtures/vcr_cassettes/lib/events/presence-sync-error.yml
|
|
@@ -10515,12 +10528,22 @@ files:
|
|
|
10515
10528
|
- fixtures/vcr_cassettes/lib/events/subscribe-async.yml
|
|
10516
10529
|
- fixtures/vcr_cassettes/lib/events/subscribe-channel-groups.yml
|
|
10517
10530
|
- fixtures/vcr_cassettes/lib/events/subscribe-cipher-async.yml
|
|
10531
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml
|
|
10532
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-member-remove-async.yml
|
|
10533
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml
|
|
10534
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml
|
|
10518
10535
|
- fixtures/vcr_cassettes/lib/events/subscribe-playing-async.yml
|
|
10536
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-space-delete-async.yml
|
|
10537
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml
|
|
10519
10538
|
- fixtures/vcr_cassettes/lib/events/subscribe-sync-error.yml
|
|
10520
10539
|
- fixtures/vcr_cassettes/lib/events/subscribe-sync.yml
|
|
10540
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-user-delete-async.yml
|
|
10541
|
+
- fixtures/vcr_cassettes/lib/events/subscribe-user-update-async.yml
|
|
10521
10542
|
- fixtures/vcr_cassettes/lib/events/subscribe-with-presence.yml
|
|
10522
10543
|
- fixtures/vcr_cassettes/lib/events/time-error.yml
|
|
10523
10544
|
- fixtures/vcr_cassettes/lib/events/time.yml
|
|
10545
|
+
- fixtures/vcr_cassettes/lib/events/update_space.yml
|
|
10546
|
+
- fixtures/vcr_cassettes/lib/events/update_user.yml
|
|
10524
10547
|
- fixtures/vcr_cassettes/lib/events/where-now-error.yml
|
|
10525
10548
|
- fixtures/vcr_cassettes/lib/events/where-now.yml
|
|
10526
10549
|
- fixtures/vcr_cassettes/lib/multiple_ciphers.yml
|