pubnub 3.7.5 → 3.7.7
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/CHANGELOG.txt +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/VERSION +1 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-false-1.yml +126 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-false-2.yml +86 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-false-3.yml +212 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-false-4.yml +168 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-true-1.yml +126 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-true-2.yml +86 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-true-3.yml +212 -0
- data/fixtures/vcr_cassettes/wc-sub-ssl-true-4.yml +168 -0
- data/lib/pubnub/envelope.rb +1 -0
- data/lib/pubnub/event.rb +112 -25
- data/lib/pubnub/events/leave.rb +12 -0
- data/lib/pubnub/events/presence.rb +2 -1
- data/lib/pubnub/events/subscribe.rb +2 -0
- data/lib/pubnub/version.rb +1 -1
- data/spec/lib/integration/wildcard_subscribe_spec.rb +150 -0
- metadata +26 -14
data/lib/pubnub/events/leave.rb
CHANGED
@@ -8,6 +8,8 @@ module Pubnub
|
|
8
8
|
|
9
9
|
def initialize(options, app)
|
10
10
|
super
|
11
|
+
@wildcard_channel = @channel.select{ |e| e.index('.*') } || []
|
12
|
+
@channel -= @wildcard_channel
|
11
13
|
@event = 'leave'
|
12
14
|
@allow_multiple_channels = true
|
13
15
|
@doesnt_require_callback = true
|
@@ -40,6 +42,11 @@ module Pubnub
|
|
40
42
|
Pubnub.logger.debug(:pubnub){"#{app.env[:subscriptions][@origin].get_channel_groups.to_s}.include? #{channel_group}"}
|
41
43
|
raise ArgumentError.new(:object => self, :message => 'You cannot leave channel group that is not subscribed') unless app.env[:subscriptions][@origin].get_channel_groups.include?(channel_group)
|
42
44
|
end
|
45
|
+
|
46
|
+
@wildcard_channel.each do |wc|
|
47
|
+
Pubnub.logger.debug(:pubnub){"#{app.env[:subscriptions][@origin].get_wildcard_channels.to_s}.include? #{wc}"}
|
48
|
+
raise ArgumentError.new(:object => self, :message => 'You cannot leave wildcard channel that is not subscribed') unless app.env[:subscriptions][@origin].get_wildcard_channels.include?(wc)
|
49
|
+
end
|
43
50
|
end unless @force
|
44
51
|
|
45
52
|
@channel.each do |channel|
|
@@ -51,6 +58,11 @@ module Pubnub
|
|
51
58
|
app.env[:subscriptions][@origin].remove_channel_group(channel_group, app) if app.env[:subscriptions][@origin]
|
52
59
|
@left = true
|
53
60
|
end unless @skip_remove
|
61
|
+
|
62
|
+
@wildcard_channel.each do |wc|
|
63
|
+
app.env[:subscriptions][@origin].remove_wildcard_channel(wc, app) if app.env[:subscriptions][@origin]
|
64
|
+
@left = true
|
65
|
+
end unless @skip_remove
|
54
66
|
end
|
55
67
|
|
56
68
|
envelopes = super
|
@@ -12,7 +12,8 @@ module Pubnub
|
|
12
12
|
@channel_group = @channel_group.map {|c| c + '-pnpres'}
|
13
13
|
@event = 'presence'
|
14
14
|
@allow_multiple_channels = true
|
15
|
-
|
15
|
+
@wildcard_channel = @channel.select{ |e| e.index('.*') } || []
|
16
|
+
@channel -= @wildcard_channel
|
16
17
|
end
|
17
18
|
|
18
19
|
def fire(app)
|
data/lib/pubnub/version.rb
CHANGED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#where_now' do
|
4
|
+
before(:each) do
|
5
|
+
EM.stop if EM.reactor_running?
|
6
|
+
while EM.reactor_running? do end
|
7
|
+
sleep(0.1)
|
8
|
+
|
9
|
+
@response_output = StringIO.new
|
10
|
+
@message_output = StringIO.new
|
11
|
+
|
12
|
+
@callback = lambda { |envelope|
|
13
|
+
Pubnub.logger.debug 'FIRING CALLBACK FROM TEST'
|
14
|
+
@response_output.write envelope.response
|
15
|
+
@message_output.write envelope.msg
|
16
|
+
@after_callback = true
|
17
|
+
}
|
18
|
+
|
19
|
+
@error_callback = lambda { |envelope|
|
20
|
+
Pubnub.logger.debug 'FIRING ERROR CALLBACK FROM TEST'
|
21
|
+
@response_output.write envelope.response
|
22
|
+
@message_output.write envelope.msg
|
23
|
+
@after_error_callback = true
|
24
|
+
}
|
25
|
+
|
26
|
+
@pn = Pubnub.new(:max_retries => 0, :subscribe_key => :ds, :publish_key => :ds, :secret_key => 'some_secret_key', :error_callback => @error_callback)
|
27
|
+
@pn.uuid = 'rubytests'
|
28
|
+
end
|
29
|
+
context 'https' do
|
30
|
+
before :each do
|
31
|
+
@ssl = true
|
32
|
+
end
|
33
|
+
it 'receives message sent to foo.bar when subscribed on foo.*' do
|
34
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-1", :record => :once) do
|
35
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*', :callback => @callback)
|
36
|
+
|
37
|
+
eventually do
|
38
|
+
@after_callback.should eq true
|
39
|
+
@response_output.seek 0
|
40
|
+
@response_output.read.should eq "[[{\"text\":\"hey\"}],\"14376641318913945\",\"foo.*\",\"foo.foo\"]"
|
41
|
+
@message_output.seek 0
|
42
|
+
@message_output.read.should eq "{\"text\"=>\"hey\"}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'is able to subscribe on foo.* and receive presence events on foo.bar-pnpress when presence callback is provided.' do
|
48
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-2", :record => :once) do
|
49
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*', :callback => @callback, :presence_callback => @callback)
|
50
|
+
|
51
|
+
eventually do
|
52
|
+
@after_callback.should eq true
|
53
|
+
@response_output.seek 0
|
54
|
+
@response_output.read.should eq "[[{\"action\": \"leave\", \"timestamp\": 1437664166, \"uuid\": \"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\": 0}],\"14376641662543427\",\"foo.*\",\"foo.foo-pnpres\"]"
|
55
|
+
@message_output.seek 0
|
56
|
+
@message_output.read.should eq "{\"action\"=>\"leave\", \"timestamp\"=>1437664166, \"uuid\"=>\"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\"=>0}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'does not receive presence events when subscribed to foo.* when presence callback is not provided.' do
|
62
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-3", :record => :once) do
|
63
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*', :callback => @callback)
|
64
|
+
|
65
|
+
eventually do
|
66
|
+
@after_callback.should eq nil
|
67
|
+
@response_output.seek 0
|
68
|
+
@response_output.read.should eq ''
|
69
|
+
@message_output.seek 0
|
70
|
+
@message_output.read.should eq ''
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'is able to bo subscribed to non-WC channel, channel group and wildcard channel at same time using multiplexing and should receive messages appropriately when message is published on corresponding channel' do
|
76
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-4", :record => :once) do
|
77
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*,foo', :group => 'group', :callback => @callback, :presence_callback => @callback)
|
78
|
+
|
79
|
+
eventually do
|
80
|
+
@after_callback.should eq true
|
81
|
+
@response_output.seek 0
|
82
|
+
@response_output.read.should eq "[[{\"text\":\"hey\"}],\"14376642242988715\",\"foo.*\",\"foo.foo\"][[{\"action\": \"leave\", \"timestamp\": 1437664227, \"uuid\": \"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\": 0}],\"14376642278720422\",\"foo.*\",\"foo.foo-pnpres\"][[{\"text\":\"hey\"}],\"14376642302336303\",\"foo\",\"foo\"]"
|
83
|
+
@message_output.seek 0
|
84
|
+
@message_output.read.should eq "{\"text\"=>\"hey\"}{\"action\"=>\"leave\", \"timestamp\"=>1437664227, \"uuid\"=>\"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\"=>0}{\"text\"=>\"hey\"}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'https' do
|
91
|
+
before :each do
|
92
|
+
@ssl = false
|
93
|
+
end
|
94
|
+
it 'receives message sent to foo.bar when subscribed on foo.*' do
|
95
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-1", :record => :once) do
|
96
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*', :callback => @callback)
|
97
|
+
|
98
|
+
eventually do
|
99
|
+
@after_callback.should eq true
|
100
|
+
@response_output.seek 0
|
101
|
+
@response_output.read.should eq "[[{\"text\":\"hey\"}],\"14376641318913945\",\"foo.*\",\"foo.foo\"]"
|
102
|
+
@message_output.seek 0
|
103
|
+
@message_output.read.should eq "{\"text\"=>\"hey\"}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'is able to subscribe on foo.* and receive presence events on foo.bar-pnpress when presence callback is provided.' do
|
109
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-2", :record => :once) do
|
110
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*', :callback => @callback, :presence_callback => @callback)
|
111
|
+
|
112
|
+
eventually do
|
113
|
+
@after_callback.should eq true
|
114
|
+
@response_output.seek 0
|
115
|
+
@response_output.read.should eq "[[{\"action\": \"leave\", \"timestamp\": 1437664166, \"uuid\": \"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\": 0}],\"14376641662543427\",\"foo.*\",\"foo.foo-pnpres\"]"
|
116
|
+
@message_output.seek 0
|
117
|
+
@message_output.read.should eq "{\"action\"=>\"leave\", \"timestamp\"=>1437664166, \"uuid\"=>\"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\"=>0}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'does not receive presence events when subscribed to foo.* when presence callback is not provided.' do
|
123
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-3", :record => :once) do
|
124
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*', :callback => @callback)
|
125
|
+
|
126
|
+
eventually do
|
127
|
+
@after_callback.should eq nil
|
128
|
+
@response_output.seek 0
|
129
|
+
@response_output.read.should eq ''
|
130
|
+
@message_output.seek 0
|
131
|
+
@message_output.read.should eq ''
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'is able to bo subscribed to non-WC channel, channel group and wildcard channel at same time using multiplexing and should receive messages appropriately when message is published on corresponding channel' do
|
137
|
+
VCR.use_cassette("wc-sub-ssl-#{@ssl}-4", :record => :once) do
|
138
|
+
@pn.subscribe(:ssl => @ssl, :channel => 'foo.*,foo', :group => 'group', :callback => @callback, :presence_callback => @callback)
|
139
|
+
|
140
|
+
eventually do
|
141
|
+
@after_callback.should eq true
|
142
|
+
@response_output.seek 0
|
143
|
+
@response_output.read.should eq "[[{\"text\":\"hey\"}],\"14376642242988715\",\"foo.*\",\"foo.foo\"][[{\"action\": \"leave\", \"timestamp\": 1437664227, \"uuid\": \"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\": 0}],\"14376642278720422\",\"foo.*\",\"foo.foo-pnpres\"][[{\"text\":\"hey\"}],\"14376642302336303\",\"foo\",\"foo\"]"
|
144
|
+
@message_output.seek 0
|
145
|
+
@message_output.read.should eq "{\"text\"=>\"hey\"}{\"action\"=>\"leave\", \"timestamp\"=>1437664227, \"uuid\"=>\"c7769435-68b3-48b0-9065-08cafce285df\", \"occupancy\"=>0}{\"text\"=>\"hey\"}"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
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.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.8'
|
34
34
|
type: :runtime
|
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: '1.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: net-http-persistent
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.9'
|
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
54
|
version: '2.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.6'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.6'
|
69
69
|
description: Ruby anywhere in the world in 250ms with PubNub!
|
@@ -73,7 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
77
77
|
- 3.5_to_3.6_upgrade_notes.md
|
78
78
|
- CHANGELOG.txt
|
79
79
|
- Gemfile
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
|
+
- VERSION
|
84
85
|
- examples/chaos/tmp/pids/passenger.3000.pid.lock
|
85
86
|
- examples/demo_console.rb
|
86
87
|
- examples/error_server.rb
|
@@ -691,6 +692,14 @@ files:
|
|
691
692
|
- fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-200-sync.yml
|
692
693
|
- fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-non-200-async.yml
|
693
694
|
- fixtures/vcr_cassettes/v3-presence-ssl-parameter-valid-non-200-sync.yml
|
695
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-false-1.yml
|
696
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-false-2.yml
|
697
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-false-3.yml
|
698
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-false-4.yml
|
699
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-true-1.yml
|
700
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-true-2.yml
|
701
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-true-3.yml
|
702
|
+
- fixtures/vcr_cassettes/wc-sub-ssl-true-4.yml
|
694
703
|
- fixtures/vcr_cassettes/where_now-ssl-block-invalid-200-async.yml
|
695
704
|
- fixtures/vcr_cassettes/where_now-ssl-block-invalid-200-sync.yml
|
696
705
|
- fixtures/vcr_cassettes/where_now-ssl-block-invalid-non-200-async.yml
|
@@ -774,6 +783,7 @@ files:
|
|
774
783
|
- spec/lib/integration/v3_presence_dpc_spec.rb
|
775
784
|
- spec/lib/integration/v3_presence_spec.rb
|
776
785
|
- spec/lib/integration/where_now_spec.rb
|
786
|
+
- spec/lib/integration/wildcard_subscribe_spec.rb
|
777
787
|
- spec/lib/retry_logic_spec.rb
|
778
788
|
- spec/lib/subscribe_event.rb
|
779
789
|
- spec/spec_helper.rb
|
@@ -787,17 +797,17 @@ require_paths:
|
|
787
797
|
- lib
|
788
798
|
required_ruby_version: !ruby/object:Gem::Requirement
|
789
799
|
requirements:
|
790
|
-
- -
|
800
|
+
- - ">="
|
791
801
|
- !ruby/object:Gem::Version
|
792
802
|
version: '0'
|
793
803
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
794
804
|
requirements:
|
795
|
-
- -
|
805
|
+
- - ">="
|
796
806
|
- !ruby/object:Gem::Version
|
797
807
|
version: '0'
|
798
808
|
requirements: []
|
799
809
|
rubyforge_project:
|
800
|
-
rubygems_version: 2.0.
|
810
|
+
rubygems_version: 2.0.2
|
801
811
|
signing_key:
|
802
812
|
specification_version: 4
|
803
813
|
summary: PubNub Official Ruby gem.
|
@@ -840,6 +850,8 @@ test_files:
|
|
840
850
|
- spec/lib/integration/v3_presence_dpc_spec.rb
|
841
851
|
- spec/lib/integration/v3_presence_spec.rb
|
842
852
|
- spec/lib/integration/where_now_spec.rb
|
853
|
+
- spec/lib/integration/wildcard_subscribe_spec.rb
|
843
854
|
- spec/lib/retry_logic_spec.rb
|
844
855
|
- spec/lib/subscribe_event.rb
|
845
856
|
- spec/spec_helper.rb
|
857
|
+
has_rdoc:
|