pubnub 4.0.13 → 4.0.14
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 +10 -2
- data/.travis.yml +3 -3
- data/CHANGELOG.md +3 -0
- data/UPGRADE_GUIDE.md +51 -0
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/examples/publish-ttl-works-ignore.yml +40 -0
- data/fixtures/vcr_cassettes/examples/publish-ttl-works.yml +40 -0
- data/lib/pubnub/events/publish.rb +40 -38
- data/lib/pubnub/version.rb +1 -1
- data/spec/examples/publish_with_ttl_spec.rb +36 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20a17fcca83f683fa37ed4f336f5c4294fda9c22
|
4
|
+
data.tar.gz: 9728fff99ed82ce3d4e5fadd2d1cea9c8684b11e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 276b78f63c539defe5b321ad6e34d487f2319dc12e721a358749a9a848b1c0cbd09c149dad22acd349212d058dfe522f758aeb721442e89d1b7b6b5e1a8781e9
|
7
|
+
data.tar.gz: c7065361f9312f1fd3c1f323a5ee5fafe1733f249ae098e214d70b077cd0c080b018bd28da3f71828229574cba196454392bcfcefc3a043b6cf1030cf4144ed3
|
data/.pubnub.yml
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
---
|
2
2
|
changelog:
|
3
|
+
-
|
4
|
+
changes:
|
5
|
+
-
|
6
|
+
text: "Added ttl parameter for publish"
|
7
|
+
type: improvement
|
8
|
+
date: ~
|
9
|
+
version: v4.0.14
|
3
10
|
-
|
4
11
|
changes:
|
5
12
|
-
|
6
13
|
text: "Changed init message log level to debug"
|
7
14
|
type: improvement
|
8
15
|
date: ~
|
9
|
-
version: v4.0.
|
16
|
+
version: v4.0.13
|
10
17
|
-
|
11
18
|
changes:
|
12
19
|
-
|
@@ -144,6 +151,7 @@ features:
|
|
144
151
|
- PUBLISH-POST
|
145
152
|
- PUBLISH-SYNC
|
146
153
|
- PUBLISH-ASYNC
|
154
|
+
- PUBLISH-MESSAGE-TTL
|
147
155
|
storage:
|
148
156
|
- STORAGE-REVERSE
|
149
157
|
- STORAGE-INCLUDE-TIMETOKEN
|
@@ -164,4 +172,4 @@ features:
|
|
164
172
|
name: ruby
|
165
173
|
schema: 1
|
166
174
|
scm: github.com/pubnub/ruby
|
167
|
-
version: "4.0.
|
175
|
+
version: "4.0.14"
|
data/.travis.yml
CHANGED
@@ -16,7 +16,7 @@ matrix:
|
|
16
16
|
- rvm: 2.3.1
|
17
17
|
- rvm: 2.2.5
|
18
18
|
- rvm: 2.1.9
|
19
|
-
- rvm: jruby-9.1.5.0
|
20
|
-
env: JRUBY_OPTS="--server -J-Xms1500m -J-Xmx1500m -J-XX:+UseConcMarkSweepGC -J-XX:-UseGCOverheadLimit -J-XX:+CMSClassUnloadingEnabled"
|
21
|
-
jdk: oraclejdk7
|
19
|
+
# - rvm: jruby-9.1.5.0
|
20
|
+
# env: JRUBY_OPTS="--server -J-Xms1500m -J-Xmx1500m -J-XX:+UseConcMarkSweepGC -J-XX:-UseGCOverheadLimit -J-XX:+CMSClassUnloadingEnabled"
|
21
|
+
# jdk: oraclejdk7
|
22
22
|
|
data/CHANGELOG.md
CHANGED
data/UPGRADE_GUIDE.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
### Upgrade Guide 3.8.x to 4.0.x
|
2
|
+
|
3
|
+
##### Envelope result
|
4
|
+
|
5
|
+
Pubnub Ruby SDK `4.x` version uses new `Envelope` object for response. You can find here how it is structured:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
envelope.id # unique envelope ID for internal usage
|
9
|
+
envelope.event # event key (:publish, :time, :grant etc.)
|
10
|
+
envelope.event_options # options given to the event when it was fired
|
11
|
+
envelope.status # status response Hash
|
12
|
+
envelope.result # result response Hash
|
13
|
+
envelope.timetoken # timetoken
|
14
|
+
```
|
15
|
+
|
16
|
+
Status and result structures for specific events can be found in our [docs](https://www.pubnub.com/docs/ruby/api-reference-sdk-v4).
|
17
|
+
|
18
|
+
##### Subscribe changes
|
19
|
+
|
20
|
+
Subscribe callbacks has been completly reworked and now uses listeners (`SubscribeCalback`).
|
21
|
+
|
22
|
+
For example, let's upgrade old code:
|
23
|
+
```
|
24
|
+
# Old code
|
25
|
+
pubnub.subscribe(channel: :demo){ |envelope| puts "MSG: #{envelope}" }
|
26
|
+
pubnub.presence(channel: :demo){ |envelope| puts "PRESENCE #{envelope}" }
|
27
|
+
|
28
|
+
# New code
|
29
|
+
|
30
|
+
# We're creating listener here
|
31
|
+
callbacks = Pubnub::SubscribeCallback.new(
|
32
|
+
# Fired for messages
|
33
|
+
message: ->(envelope) {
|
34
|
+
puts "MSG: #{envelope.result}" if envelope.result[:data][:message_meta_data]['uuid'] != pubnub.uuid
|
35
|
+
},
|
36
|
+
# Fired for presence events
|
37
|
+
presence: ->(envelope) {
|
38
|
+
puts "PRESENCE #{envelope.result}"
|
39
|
+
},
|
40
|
+
# Fired for status events (like `connected`)
|
41
|
+
status: ->(envelope) {
|
42
|
+
puts "STATUS #{envelope.status}"
|
43
|
+
}
|
44
|
+
)
|
45
|
+
|
46
|
+
# Here it's added to listeners
|
47
|
+
pubnub.add_listener(callback: callbacks)
|
48
|
+
|
49
|
+
# Finally we're firing subscribe
|
50
|
+
pubnub.subscribe(channel: :demo, presence: :demo)
|
51
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.
|
1
|
+
4.0.14
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://pubsub.pubnub.com/publish/pub-c-b42cec2f-f468-4784-8833-dd2b074538c4/sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f/0/demo/0/%22whatever%22?auth=ruby-test-auth-client-one&ortt=%7B%22t%22:14782579046347514%7D&pnsdk=PubNub-Ruby/4.0.13&seqn=1&store=0&uuid=ruby-test-uuid-client-one
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.2.4, ruby 2.3.1 (2016-04-26))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Fri, 04 Nov 2016 11:11:44 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Fri, 04 Nov 2016 11:11:44 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '30'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Allow-Methods:
|
34
|
+
- GET
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '[1,"Sent","14782579047413313"]'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Fri, 04 Nov 2016 11:11:44 GMT
|
40
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://pubsub.pubnub.com/publish/pub-c-b42cec2f-f468-4784-8833-dd2b074538c4/sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f/0/demo/0/%22whatever%22?auth=ruby-test-auth-client-one&ortt=%7B%22t%22:14782579044932096%7D&pnsdk=PubNub-Ruby/4.0.13&seqn=1&ttl=10&uuid=ruby-test-uuid-client-one
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.2.4, ruby 2.3.1 (2016-04-26))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Fri, 04 Nov 2016 11:11:44 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Fri, 04 Nov 2016 11:11:44 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '30'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Cache-Control:
|
30
|
+
- no-cache
|
31
|
+
Access-Control-Allow-Origin:
|
32
|
+
- "*"
|
33
|
+
Access-Control-Allow-Methods:
|
34
|
+
- GET
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '[1,"Sent","14782579046000962"]'
|
38
|
+
http_version:
|
39
|
+
recorded_at: Fri, 04 Nov 2016 11:11:44 GMT
|
40
|
+
recorded_with: VCR 3.0.1
|
@@ -10,15 +10,16 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = :publish
|
12
12
|
super
|
13
|
-
@sequence_number
|
13
|
+
@sequence_number = sequence_number!
|
14
14
|
@origination_time_token = @app.generate_ortt
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
case @store
|
17
|
+
when false
|
18
|
+
@store = 0
|
19
|
+
@ttl = nil
|
20
|
+
when true
|
21
|
+
@store = 1
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def fire
|
@@ -48,30 +49,31 @@ module Pubnub
|
|
48
49
|
params = super
|
49
50
|
|
50
51
|
empty_if_blank = {
|
51
|
-
|
52
|
-
|
52
|
+
store: @store,
|
53
|
+
meta: @meta,
|
54
|
+
ttl: @ttl
|
53
55
|
}
|
54
56
|
|
55
|
-
replication = @replicate == false ? {
|
57
|
+
replication = @replicate == false ? {norep: true} : {}
|
56
58
|
|
57
59
|
empty_if_blank.delete_if { |_k, v| v.blank? }
|
58
60
|
|
59
61
|
params = params.merge(empty_if_blank)
|
60
62
|
params = params.merge(replication)
|
61
63
|
params = params.merge(seqn: @sequence_number,
|
62
|
-
ortt: {
|
64
|
+
ortt: {t: @origination_time_token})
|
63
65
|
params
|
64
66
|
end
|
65
67
|
|
66
68
|
def path
|
67
69
|
rpath = [
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
'publish',
|
71
|
+
@publish_key,
|
72
|
+
@subscribe_key,
|
73
|
+
'0',
|
74
|
+
@channel,
|
75
|
+
'0',
|
76
|
+
Formatter.format_message(@message, @cipher_key)
|
75
77
|
]
|
76
78
|
|
77
79
|
rpath.pop if @compressed
|
@@ -97,26 +99,26 @@ module Pubnub
|
|
97
99
|
|
98
100
|
def valid_envelope(_parsed_response, req_res_objects)
|
99
101
|
Pubnub::Envelope.new(
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
102
|
+
event: @event,
|
103
|
+
event_options: @given_options,
|
104
|
+
timetoken: nil,
|
105
|
+
status: {
|
106
|
+
code: req_res_objects[:response].code,
|
107
|
+
operation: Pubnub::Constants::OPERATION_PUBLISH,
|
108
|
+
client_request: req_res_objects[:request],
|
109
|
+
server_response: req_res_objects[:response],
|
110
|
+
data: nil,
|
111
|
+
category: Pubnub::Constants::STATUS_ACK,
|
112
|
+
error: false,
|
113
|
+
auto_retried: false,
|
114
|
+
|
115
|
+
current_timetoken: nil,
|
116
|
+
last_timetoken: nil,
|
117
|
+
subscribed_channels: nil,
|
118
|
+
subscribed_channel_groups: nil,
|
119
|
+
|
120
|
+
config: get_config
|
121
|
+
}
|
120
122
|
)
|
121
123
|
end
|
122
124
|
end
|
data/lib/pubnub/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pubnub::Publish do
|
4
|
+
around :each do |example|
|
5
|
+
@pubnub = Pubnub::Client.new(
|
6
|
+
publish_key: 'pub-c-b42cec2f-f468-4784-8833-dd2b074538c4',
|
7
|
+
subscribe_key: 'sub-c-b7fb805a-1777-11e6-be83-0619f8945a4f',
|
8
|
+
uuid: 'ruby-test-uuid-client-one',
|
9
|
+
auth_key: 'ruby-test-auth-client-one'
|
10
|
+
)
|
11
|
+
|
12
|
+
Celluloid.boot
|
13
|
+
example.run
|
14
|
+
Celluloid.shutdown
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with specified ttl parameter' do
|
18
|
+
it 'adds it to url' do
|
19
|
+
VCR.use_cassette('examples/publish-ttl-works', record: :once) do
|
20
|
+
envelope = @pubnub.publish(channel: :demo, message: :whatever, ttl: 10, http_sync: true)
|
21
|
+
|
22
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
23
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'ignores it when store is false' do
|
28
|
+
VCR.use_cassette('examples/publish-ttl-works-ignore', record: :once) do
|
29
|
+
envelope = @pubnub.publish(channel: :demo, message: :whatever, ttl: 10, store: false, http_sync: true)
|
30
|
+
|
31
|
+
expect(envelope.is_a?(Pubnub::Envelope)).to eq true
|
32
|
+
expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.0.
|
4
|
+
version: 4.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- LICENSE.txt
|
106
106
|
- README.md
|
107
107
|
- Rakefile
|
108
|
+
- UPGRADE_GUIDE.md
|
108
109
|
- VERSION
|
109
110
|
- docs.md
|
110
111
|
- fixtures/vcr_cassettes/client/connection_callbacks_0.yml
|
@@ -3836,6 +3837,8 @@ files:
|
|
3836
3837
|
- fixtures/vcr_cassettes/examples/presence/7.yml
|
3837
3838
|
- fixtures/vcr_cassettes/examples/presence/8.yml
|
3838
3839
|
- fixtures/vcr_cassettes/examples/presence/9.yml
|
3840
|
+
- fixtures/vcr_cassettes/examples/publish-ttl-works-ignore.yml
|
3841
|
+
- fixtures/vcr_cassettes/examples/publish-ttl-works.yml
|
3839
3842
|
- fixtures/vcr_cassettes/examples/publish/00137969798b5dd71da12968bfd6ebdd311021fd1e29f19921a4aff3111670bc.yml
|
3840
3843
|
- fixtures/vcr_cassettes/examples/publish/001707bf2681b5de81316e8cae525f4fd3156c405b35f880c38d01fa037b8960.yml
|
3841
3844
|
- fixtures/vcr_cassettes/examples/publish/001d69e899ba9eb547a4c21d5aaa61299a3a58bc37aa289bd657f2c8a83fa0ee.yml
|
@@ -10552,6 +10555,7 @@ files:
|
|
10552
10555
|
- spec/examples/leave_examples_spec.rb
|
10553
10556
|
- spec/examples/presence_examples_spec.rb
|
10554
10557
|
- spec/examples/publish_examples_spec.rb
|
10558
|
+
- spec/examples/publish_with_ttl_spec.rb
|
10555
10559
|
- spec/examples/revoke_examples_spec.rb
|
10556
10560
|
- spec/examples/set_state_examples_spec.rb
|
10557
10561
|
- spec/examples/state_examples_spec.rb
|
@@ -10620,6 +10624,7 @@ test_files:
|
|
10620
10624
|
- spec/examples/leave_examples_spec.rb
|
10621
10625
|
- spec/examples/presence_examples_spec.rb
|
10622
10626
|
- spec/examples/publish_examples_spec.rb
|
10627
|
+
- spec/examples/publish_with_ttl_spec.rb
|
10623
10628
|
- spec/examples/revoke_examples_spec.rb
|
10624
10629
|
- spec/examples/set_state_examples_spec.rb
|
10625
10630
|
- spec/examples/state_examples_spec.rb
|