pubnub 4.0.23 → 4.0.25
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.pubnub.yml +18 -1
- data/.travis.yml +23 -6
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +59 -50
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/examples/delete_messages_channel.yml +46 -0
- data/fixtures/vcr_cassettes/examples/delete_messages_channel_end.yml +46 -0
- data/fixtures/vcr_cassettes/examples/delete_messages_channel_start.yml +46 -0
- data/fixtures/vcr_cassettes/examples/delete_messages_channel_start_end.yml +46 -0
- data/fixtures/vcr_cassettes/lib/events/delete_messages-error.yml +46 -0
- data/fixtures/vcr_cassettes/lib/events/delete_messages.yml +46 -0
- data/gemfiles/celluloid_017.gemfile +25 -0
- data/gemfiles/celluloid_017.gemfile.lock +159 -0
- data/gemfiles/celluloid_018.gemfile +25 -0
- data/gemfiles/celluloid_018.gemfile.lock +159 -0
- data/gemfiles/celluloid_master.gemfile +25 -0
- data/gemfiles/celluloid_master.gemfile.lock +155 -0
- data/lib/pubnub.rb +3 -0
- data/lib/pubnub/client.rb +13 -1
- data/lib/pubnub/client/events.rb +1 -1
- data/lib/pubnub/constants.rb +1 -0
- data/lib/pubnub/event.rb +20 -5
- data/lib/pubnub/event/formatter.rb +1 -3
- data/lib/pubnub/events/channel_registration.rb +1 -0
- data/lib/pubnub/events/delete_messages.rb +63 -0
- data/lib/pubnub/events/heartbeat.rb +1 -0
- data/lib/pubnub/events/here_now.rb +1 -0
- data/lib/pubnub/events/history.rb +1 -0
- data/lib/pubnub/events/leave.rb +1 -0
- data/lib/pubnub/events/presence.rb +1 -0
- data/lib/pubnub/events/publish.rb +1 -0
- data/lib/pubnub/events/set_state.rb +1 -0
- data/lib/pubnub/events/state.rb +1 -0
- data/lib/pubnub/events/time.rb +1 -0
- data/lib/pubnub/events/where_now.rb +1 -0
- data/lib/pubnub/pam.rb +2 -1
- data/lib/pubnub/telemetry.rb +29 -0
- data/lib/pubnub/validators/delete.rb +24 -0
- data/lib/pubnub/version.rb +1 -1
- data/spec/examples/audit_examples_spec.rb +3 -1
- data/spec/examples/channel_registration_examples_spec.rb +3 -1
- data/spec/examples/delete_messages_examples_spec.rb +48 -0
- data/spec/examples/grant_examples_spec.rb +2 -2
- data/spec/examples/heartbeat_examples_spec.rb +2 -2
- data/spec/examples/here_now_examples_spec.rb +2 -2
- data/spec/examples/history_examples_spec.rb +2 -2
- data/spec/examples/leave_examples_spec.rb +2 -2
- data/spec/examples/presence_examples_spec.rb +2 -2
- data/spec/examples/publish_examples_spec.rb +2 -2
- data/spec/examples/publish_with_ttl_spec.rb +3 -2
- data/spec/examples/revoke_examples_spec.rb +2 -2
- data/spec/examples/set_state_examples_spec.rb +2 -2
- data/spec/examples/state_examples_spec.rb +2 -2
- data/spec/examples/subscribe_examples_spec.rb +2 -2
- data/spec/examples/time_examples_spec.rb +2 -2
- data/spec/examples/where_now_examples_spec.rb +2 -2
- data/spec/lib/events/delete_messages_spec.rb +43 -0
- data/spec/lib/events/grant_spec.rb +27 -28
- data/spec/lib/events/timeout_handling_spec.rb +20 -14
- data/spec/lib/pubnub_spec.rb +7 -1
- data/spec/spec_helper.rb +21 -0
- metadata +22 -3
data/lib/pubnub/events/state.rb
CHANGED
data/lib/pubnub/events/time.rb
CHANGED
data/lib/pubnub/pam.rb
CHANGED
@@ -6,6 +6,7 @@ module Pubnub
|
|
6
6
|
super
|
7
7
|
|
8
8
|
@auth_key = options[:auth_key]
|
9
|
+
@telemetry_name = :l_pam
|
9
10
|
|
10
11
|
# @channel += format_channels(options[:presence]).map do |c|
|
11
12
|
# c + '-pnpres'
|
@@ -85,7 +86,7 @@ module Pubnub
|
|
85
86
|
when JSON::ParserError
|
86
87
|
error_category = Pubnub::Constants::STATUS_NON_JSON_RESPONSE
|
87
88
|
code = req_res_objects[:response].code
|
88
|
-
when HTTPClient::
|
89
|
+
when HTTPClient::TimeoutError
|
89
90
|
error_category = Pubnub::Constants::STATUS_TIMEOUT
|
90
91
|
code = 408
|
91
92
|
else
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Pubnub
|
2
|
+
class Telemetry
|
3
|
+
include Celluloid
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@timers, @good_to_go, @recorded_history = {}, {}, {}
|
7
|
+
Pubnub.logger.debug('Pubnub::Telementry') { 'Initialized Telemetry'}
|
8
|
+
end
|
9
|
+
|
10
|
+
def record_request(telemetry_type, time_start, time_end)
|
11
|
+
@timers[telemetry_type] = every(1) { @good_to_go[telemetry_type] = true } unless @timers[telemetry_type]
|
12
|
+
@recorded_history[telemetry_type] ||= []
|
13
|
+
@recorded_history[telemetry_type] << time_end - time_start
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch_average(telemetry_type)
|
17
|
+
@recorded_history[telemetry_type] ||= []
|
18
|
+
return false if !@good_to_go[telemetry_type] || @recorded_history[telemetry_type].size == 0
|
19
|
+
average = @recorded_history[telemetry_type].reduce(0, :+) / @recorded_history[telemetry_type].size
|
20
|
+
clear!(telemetry_type)
|
21
|
+
average
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear!(telemetry_type)
|
25
|
+
@recorded_history[telemetry_type] = []
|
26
|
+
@good_to_go[telemetry_type] = false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Toplevel Pubnub module.
|
2
|
+
module Pubnub
|
3
|
+
# Validator module that holds all validators modules
|
4
|
+
module Validator
|
5
|
+
# Validator for Grant event
|
6
|
+
module Delete
|
7
|
+
include CommonValidator
|
8
|
+
|
9
|
+
def validate!
|
10
|
+
return if @skip_validate
|
11
|
+
validate_channel!
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def validate_channel!
|
17
|
+
fail(
|
18
|
+
ArgumentError.new,
|
19
|
+
'You have to call #delete on single channel'
|
20
|
+
) if @channel.blank? || @channel.index(',')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/pubnub/version.rb
CHANGED
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Audit do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -16,8 +18,8 @@ describe Pubnub::Audit do
|
|
16
18
|
auth_key: 'ruby-test-auth-client-one'
|
17
19
|
)
|
18
20
|
|
19
|
-
Celluloid.boot
|
20
21
|
example.run
|
22
|
+
|
21
23
|
Celluloid.shutdown
|
22
24
|
end
|
23
25
|
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::ChannelRegistration do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,8 +17,8 @@ describe Pubnub::ChannelRegistration do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
21
|
+
|
20
22
|
Celluloid.shutdown
|
21
23
|
end
|
22
24
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pubnub::ChannelRegistration do
|
4
|
+
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
example.run
|
7
|
+
Celluloid.shutdown
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'whatever' do
|
11
|
+
let(:pubnub) do
|
12
|
+
Pubnub::Client.new(
|
13
|
+
subscribe_key: 'sub-c-fc6c9226-655d-11e7-b272-02ee2ddab7fe',
|
14
|
+
publish_key: 'pub-c-b458bb23-c95d-4f43-9992-e2c118557e80',
|
15
|
+
auth_key: 'ruby-test-auth',
|
16
|
+
uuid: 'ruby-test-uuid'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'works with just channel specified' do
|
21
|
+
VCR.use_cassette('examples/delete_messages_channel',record: :once) do
|
22
|
+
envelope = pubnub.delete_messages(channel: :demo)
|
23
|
+
expect(envelope.value.status[:code]).to eq 200
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'works with channel and start specified' do
|
28
|
+
VCR.use_cassette('examples/delete_messages_channel_start',record: :once) do
|
29
|
+
envelope = pubnub.delete_messages(channel: :demo, start: '15040071432538531')
|
30
|
+
expect(envelope.value.status[:code]).to eq 200
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'works with channel, start and end specified' do
|
35
|
+
VCR.use_cassette('examples/delete_messages_channel_start_end',record: :once) do
|
36
|
+
envelope = pubnub.delete_messages(channel: :demo, start: '1504003597000', end: '1504007197000')
|
37
|
+
expect(envelope.value.status[:code]).to eq 200
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'works with channel and end specified' do
|
42
|
+
VCR.use_cassette('examples/delete_messages_channel_end',record: :once) do
|
43
|
+
envelope = pubnub.delete_messages(channel: :demo, end: '15040071432538531')
|
44
|
+
expect(envelope.value.status[:code]).to eq 200
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Grant do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -16,7 +18,6 @@ describe Pubnub::Grant do
|
|
16
18
|
auth_key: 'ruby-test-auth-client-one'
|
17
19
|
)
|
18
20
|
|
19
|
-
Celluloid.boot
|
20
21
|
example.run
|
21
22
|
Celluloid.shutdown
|
22
23
|
end
|
@@ -39874,4 +39875,3 @@ end
|
|
39874
39875
|
|
39875
39876
|
|
39876
39877
|
end
|
39877
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Heartbeat do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::Heartbeat do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -813,4 +814,3 @@ end
|
|
813
814
|
|
814
815
|
|
815
816
|
end
|
816
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::HereNow do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::HereNow do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -687,4 +688,3 @@ end
|
|
687
688
|
|
688
689
|
|
689
690
|
end
|
690
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::History do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::History do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -1353,4 +1354,3 @@ end
|
|
1353
1354
|
|
1354
1355
|
|
1355
1356
|
end
|
1356
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Leave do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::Leave do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -615,4 +616,3 @@ end
|
|
615
616
|
|
616
617
|
|
617
618
|
end
|
618
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Presence do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -16,7 +18,6 @@ describe Pubnub::Presence do
|
|
16
18
|
reconnect_interval: 0
|
17
19
|
)
|
18
20
|
|
19
|
-
Celluloid.boot
|
20
21
|
example.run
|
21
22
|
Celluloid.shutdown
|
22
23
|
end
|
@@ -876,4 +877,3 @@ end
|
|
876
877
|
|
877
878
|
|
878
879
|
end
|
879
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Publish do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::Publish do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -33717,4 +33718,3 @@ end
|
|
33717
33718
|
|
33718
33719
|
|
33719
33720
|
end
|
33720
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Publish do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@pubnub = Pubnub::Client.new(
|
6
8
|
publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
|
7
9
|
subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
|
@@ -9,7 +11,6 @@ describe Pubnub::Publish do
|
|
9
11
|
auth_key: 'ruby-test-auth-client-one'
|
10
12
|
)
|
11
13
|
|
12
|
-
Celluloid.boot
|
13
14
|
example.run
|
14
15
|
Celluloid.shutdown
|
15
16
|
end
|
@@ -33,4 +34,4 @@ describe Pubnub::Publish do
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
36
|
-
end
|
37
|
+
end
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Revoke do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -16,7 +18,6 @@ describe Pubnub::Revoke do
|
|
16
18
|
auth_key: 'ruby-test-auth-client-one'
|
17
19
|
)
|
18
20
|
|
19
|
-
Celluloid.boot
|
20
21
|
example.run
|
21
22
|
Celluloid.shutdown
|
22
23
|
end
|
@@ -79726,4 +79727,3 @@ end
|
|
79726
79727
|
|
79727
79728
|
|
79728
79729
|
end
|
79729
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::SetState do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::SetState do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -417,4 +418,3 @@ end
|
|
417
418
|
|
418
419
|
|
419
420
|
end
|
420
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::State do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::State do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -243,4 +244,3 @@ end
|
|
243
244
|
|
244
245
|
|
245
246
|
end
|
246
|
-
|
@@ -2,6 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Pubnub::Subscribe do
|
4
4
|
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
|
5
7
|
@fired = false
|
6
8
|
|
7
9
|
@callback = ->(_envelope) do
|
@@ -15,7 +17,6 @@ describe Pubnub::Subscribe do
|
|
15
17
|
auth_key: 'ruby-test-auth-client-one'
|
16
18
|
)
|
17
19
|
|
18
|
-
Celluloid.boot
|
19
20
|
example.run
|
20
21
|
Celluloid.shutdown
|
21
22
|
end
|
@@ -53373,4 +53374,3 @@ end
|
|
53373
53374
|
|
53374
53375
|
|
53375
53376
|
end
|
53376
|
-
|