pubnub 3.8.2 → 3.8.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 589a06d46675772563abee39dfdb97cf852c1055
4
- data.tar.gz: bcf337cd2289ccfa8856da7c5721ae19dacf038d
3
+ metadata.gz: b740b21f8ca919ebf7f7e9a2ff32bbc837bb286d
4
+ data.tar.gz: da514132beb2de147a7dd8094e3559f75c79b054
5
5
  SHA512:
6
- metadata.gz: 8e587fab2eb014182b979d9769d25a7596a1ce17f934deb1ec8b0233aac1801fed3c8f36e582893e35c6dd593897f9b63ae7b2cccca28ceb9c8eba54422022a3
7
- data.tar.gz: 1b1a3fd598b818b09c99312b6a5b59163c49d0f6b8dea96fb6dddfc737fe6ad9833485ed01e51829e8a49a9960ba740194f831273eec15ad66cfd460bfa4ca59
6
+ metadata.gz: 6e9ed5b8d2afea4165cf0b524da6bc998f2bfaea93b4b8f39dcb1aaea5aa1002ebfa4ed11a3f4cb29ee38506f1c26aeae932e62781e95a6a9acf0ade5155a3d5
7
+ data.tar.gz: e214a9b3eee594176be3e5b82acf0263a55558e6c87b204005cb35f2b09be9ea4ec32c879b09be0be2bf8446c2650c26a9b59aa69ef40410de126047baccc69e
data/.gitignore CHANGED
@@ -7,4 +7,3 @@ log/*
7
7
  *.log
8
8
  examples/test.rb
9
9
  coverage
10
- dev_scripts
@@ -1,8 +1,11 @@
1
+ ##### 3.8.3
2
+ * Restored auth_key and uuid setters. Important notice: they will be removed in v4 of this library.
3
+
1
4
  ##### 3.8.2
2
- * Decoding fixed
5
+ * Added :include_token parameter to history call.
3
6
 
4
7
  ##### 3.8.1
5
- * Updated celluloid dependency
8
+ * Updated celluloid dependency.
6
9
 
7
10
  ##### 3.8.0
8
11
  * Release of celluloid version of pubnub gem. It's complete rewrite but public API doesn't change.
data/Gemfile CHANGED
@@ -15,4 +15,4 @@ end
15
15
  group :development do
16
16
  gem 'pry'
17
17
  gem 'awesome_print'
18
- end
18
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pubnub (3.8.2)
4
+ pubnub (3.8.4)
5
5
  celluloid (~> 0.17)
6
6
  httpclient (~> 2.6)
7
7
  json (~> 1.8)
@@ -45,11 +45,13 @@ GEM
45
45
  docile (1.1.5)
46
46
  domain_name (0.5.25)
47
47
  unf (>= 0.0.5, < 1.0.0)
48
+ ffi (1.9.10)
48
49
  ffi (1.9.10-java)
49
50
  hitimes (1.2.4)
51
+ hitimes (1.2.4-java)
50
52
  http-cookie (1.0.2)
51
53
  domain_name (~> 0.5)
52
- httpclient (2.8.1)
54
+ httpclient (2.8.3)
53
55
  json (1.8.3)
54
56
  json (1.8.3-java)
55
57
  method_source (0.8.2)
@@ -105,7 +107,7 @@ GEM
105
107
  term-ansicolor (1.3.2)
106
108
  tins (~> 1.0)
107
109
  thor (0.19.1)
108
- timers (4.1.1)
110
+ timers (4.1.2)
109
111
  hitimes
110
112
  tins (1.6.0)
111
113
  unf (0.1.4)
@@ -135,4 +137,4 @@ DEPENDENCIES
135
137
  webmock
136
138
 
137
139
  BUNDLED WITH
138
- 1.12.5
140
+ 1.14.4
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Please direct all Support Questions and Concerns to Support@PubNub.com
5
5
 
6
- ## PubNub Gem version 3.8.2
6
+ ## PubNub Gem version 3.8.3
7
7
 
8
8
  ##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
9
9
  ##### http://www.pubnub.com/account
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.8.1
1
+ 3.8.4
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://pubsub.pubnub.com/v2/history/sub-key/demo/channel/bot?auth=demoish_authkey&count=4&include_token=true&pnsdk=PubNub-Ruby/3.8.1&uuid=rubytests
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - HTTPClient/1.0 (2.7.1, ruby 2.2.2 (2015-04-13))
12
+ Accept:
13
+ - "*/*"
14
+ Date:
15
+ - Wed, 13 Apr 2016 10:50:10 GMT
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Wed, 13 Apr 2016 10:50:11 GMT
23
+ Content-Type:
24
+ - text/javascript; charset="UTF-8"
25
+ Content-Length:
26
+ - '387'
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
+ Accept-Ranges:
36
+ - bytes
37
+ Age:
38
+ - '0'
39
+ Server:
40
+ - Pubnub
41
+ body:
42
+ encoding: UTF-8
43
+ string: '[[{"message":"******......... 3491 - 2016-04-13 03:50:06","timetoken":14605446066210865},{"message":"*******........
44
+ 3492 - 2016-04-13 03:50:07","timetoken":14605446077902610},{"message":"********.......
45
+ 3493 - 2016-04-13 03:50:08","timetoken":14605446089621213},{"message":"*********......
46
+ 3494 - 2016-04-13 03:50:10","timetoken":14605446101325777}],14605446066210865,14605446101325777]'
47
+ http_version:
48
+ recorded_at: Wed, 13 Apr 2016 10:50:11 GMT
49
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://pubsub.pubnub.com/publish/demo/demo/0/ruby_demo_channel/0/%7B%22text%22:%22sometext%22%7D?auth=demoish_authkey&meta=%7B%22region%22:%22west%22%7D&pnsdk=PubNub-Ruby/3.8.0&uuid=tester
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - HTTPClient/1.0 (2.7.1, ruby 2.2.2 (2015-04-13))
12
+ Accept:
13
+ - "*/*"
14
+ Date:
15
+ - Wed, 10 Feb 2016 16:49:47 GMT
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Wed, 10 Feb 2016 16:49:47 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","14551229878229279"]'
38
+ http_version:
39
+ recorded_at: Wed, 10 Feb 2016 16:49:47 GMT
40
+ recorded_with: VCR 2.9.3
@@ -344,6 +344,22 @@ module Pubnub
344
344
  totally_empty @env[:state]
345
345
  end
346
346
 
347
+ def set_auth_key(key)
348
+ @env[:auth_key] = key
349
+ end
350
+
351
+ def auth_key=(key)
352
+ set_auth_key(key)
353
+ end
354
+
355
+ def set_uuid(uuid)
356
+ @env[:uuid] = uuid
357
+ end
358
+
359
+ def uuid=(uuid)
360
+ set_uuid(uuid)
361
+ end
362
+
347
363
  private
348
364
 
349
365
  def create_state_pools(event)
@@ -43,7 +43,7 @@ module Pubnub
43
43
  plain_text = decode_cipher.update(undecoded_text)
44
44
  plain_text << decode_cipher.final
45
45
  rescue => e
46
- Pubnub.logger.error('Pubnub') { "DECRYPTION ERROR #{e}" }
46
+ Pubnub.error('Pubnub') { "DECRYPTION ERROR #{e}" }
47
47
  '"DECRYPTION ERROR"'
48
48
  end
49
49
 
@@ -152,9 +152,8 @@ module Pubnub
152
152
  open_timeout read_timeout idle_timeout heartbeat
153
153
  group action read write manage ttl presence start
154
154
  end count reverse presence_callback store skip_validate
155
- state channel_group compressed)
155
+ state channel_group compressed meta include_token)
156
156
 
157
- # options = options.reduce({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }
158
157
  options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last }
159
158
 
160
159
  variables.each { |variable| instance_variable_set('@' + variable, options[variable.to_sym]) unless variable.nil? }
@@ -12,10 +12,20 @@ module Pubnub
12
12
 
13
13
  private
14
14
 
15
- def timetoken(parsed_response)
16
- parsed_response[2]
17
- rescue
18
- nil
15
+ def timetoken(message)
16
+ if @include_token
17
+ message['timetoken']
18
+ else
19
+ nil
20
+ end
21
+ end
22
+
23
+ def message(message)
24
+ if @include_token
25
+ message['message']
26
+ else
27
+ message
28
+ end
19
29
  end
20
30
 
21
31
  def response_message(parsed_response)
@@ -37,10 +47,11 @@ module Pubnub
37
47
 
38
48
  def parameters
39
49
  params = super
40
- params.merge!(start: @start) if @start
41
- params.merge!(end: @end) if @end
42
- params.merge!(count: @count) if @count
43
- params.merge!(reverse: 'true') if @reverse
50
+ params.merge!(start: @start) if @start
51
+ params.merge!(end: @end) if @end
52
+ params.merge!(count: @count) if @count
53
+ params.merge!(reverse: 'true') if @reverse
54
+ params.merge!(include_token: 'true') if @include_token
44
55
  params
45
56
  end
46
57
 
@@ -59,19 +70,12 @@ module Pubnub
59
70
  end
60
71
 
61
72
  def valid_envelopes(parsed_response)
62
-
63
- crypto = Pubnub::Crypto.new(@app.env[:cipher_key]) if @app.env[:cipher_key]
64
-
65
73
  parsed_response.first.map do |message|
66
- if crypto && message
67
- message = crypto.decrypt(message)
68
- end
69
-
70
74
  Envelope.new(parsed_response: parsed_response,
71
- message: message,
75
+ message: message(message),
72
76
  channel: @channel.first,
73
77
  response_message: response_message(parsed_response),
74
- timetoken: timetoken(parsed_response),
78
+ timetoken: timetoken(message),
75
79
  history_start: parsed_response[1],
76
80
  history_end: parsed_response[2])
77
81
  end
@@ -40,7 +40,8 @@ module Pubnub
40
40
 
41
41
  def parameters
42
42
  empty_if_blank = {
43
- store: @store
43
+ store: @store,
44
+ meta: @meta
44
45
  }
45
46
 
46
47
  empty_if_blank.delete_if { |_k, v| v.blank? }
@@ -79,7 +79,12 @@ module Pubnub
79
79
  def params_hash_to_url_params(hash)
80
80
  params = ''
81
81
  hash.each do |key, value|
82
- params << "#{key}=#{value}&"
82
+ if %w(meta).include?(key.to_s)
83
+ encoded_value = URI.encode_www_form_component(value.to_json).gsub('+', '%20')
84
+ params << "#{key}=#{encoded_value}&"
85
+ else
86
+ params << "#{key}=#{value}&"
87
+ end
83
88
  end
84
89
  params.chop! if params[-1] == '&'
85
90
  end
@@ -21,10 +21,6 @@ module Pubnub
21
21
  group = nil
22
22
  end
23
23
 
24
- if @app.env[:cipher_key] && msg
25
- msg = Pubnub::Crypto.new(@app.env[:cipher_key]).decrypt(msg)
26
- end
27
-
28
24
  Envelope.new(
29
25
  parsed_response: parsed_response,
30
26
  message: msg,
@@ -12,6 +12,7 @@ module Pubnub
12
12
  validate_channel!
13
13
  validate_message!
14
14
  validate_store!
15
+ validate_meta!
15
16
  end
16
17
 
17
18
  private
@@ -43,6 +44,13 @@ module Pubnub
43
44
  ':message is required for publish event.'
44
45
  ) if @message.nil?
45
46
  end
47
+
48
+ def validate_meta!
49
+ fail(
50
+ ArgumentError.new,
51
+ ':meta parameter must me hash.'
52
+ ) if !@meta.nil? && @meta.class != Hash
53
+ end
46
54
  end
47
55
  end
48
56
  end
@@ -1,4 +1,4 @@
1
1
  # Toplevel Pubnub module.
2
2
  module Pubnub
3
- VERSION = '3.8.2'
3
+ VERSION = '3.8.4'
4
4
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'http://github.com/pubnub/ruby'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.post_install_message = %Q(-----\nUPGRADE NOTICE: Pubnub 3.8.0 and higher versions are using Celluloid instead of EventMachine for asynchronous processing.\n-----)
16
+ spec.post_install_message = %(-----\nUPGRADE NOTICE: Pubnub 3.8.0 and higher versions are using Celluloid instead of EventMachine for asynchronous processing.\n-----)
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0")
19
19
  spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
@@ -298,4 +298,24 @@ describe Pubnub::History do
298
298
  end
299
299
  end
300
300
  end
301
+
302
+ context 'specific for include_token' do
303
+ it 'works fine with include_token' do
304
+ VCR.use_cassette('integration/history/include_token', :record => :once) do
305
+ enve = @pn.history(http_sync: true, channel: 'bot', count: 4, callback: @callback, include_token: true)
306
+
307
+ enve[0].message.should eq '******......... 3491 - 2016-04-13 03:50:06'
308
+ enve[0].timetoken.should eq 14605446066210865
309
+
310
+ enve[1].message.should eq '*******........ 3492 - 2016-04-13 03:50:07'
311
+ enve[1].timetoken.should eq 14605446077902610
312
+
313
+ enve[2].message.should eq '********....... 3493 - 2016-04-13 03:50:08'
314
+ enve[2].timetoken.should eq 14605446089621213
315
+
316
+ enve[3].message.should eq '*********...... 3494 - 2016-04-13 03:50:10'
317
+ enve[3].timetoken.should eq 14605446101325777
318
+ end
319
+ end
320
+ end
301
321
  end
@@ -1114,4 +1114,51 @@ describe Pubnub::Publish do
1114
1114
  end
1115
1115
  end
1116
1116
  end
1117
+
1118
+ context ':meta parameter' do
1119
+ before(:each) do
1120
+ @pubnub = Pubnub.new(
1121
+ :max_retries => 0,
1122
+ :subscribe_key => :demo,
1123
+ :publish_key => :demo,
1124
+ :auth_key => :demoish_authkey,
1125
+ :secret_key => 'some_secret_key',
1126
+ :error_callback => @error_callback
1127
+
1128
+ )
1129
+
1130
+ @pubnub.uuid = 'tester'
1131
+ end
1132
+
1133
+ it 'works fine' do
1134
+ VCR.use_cassette('integration/publish/publish-meta', :record => :once) do
1135
+
1136
+ @pubnub.publish(
1137
+ message: { text: 'sometext' },
1138
+ channel: 'ruby_demo_channel',
1139
+ callback: @callback,
1140
+ http_sync: true,
1141
+ meta: { region: :west }
1142
+ )
1143
+
1144
+ @envelopes.size.should eq 1
1145
+ # @envelopes.first.response_message.should eq 'Sent'
1146
+ # @envelopes.first.status.should eq 200
1147
+ # @envelopes.first.channel.should eq 'ruby_demo_channel'
1148
+ # @envelopes.first.message.should eq({:text => 'sometext'})
1149
+ # @envelopes.first.timetoken.should eq '13936818988607190'
1150
+
1151
+ end
1152
+ end
1153
+
1154
+ it 'is validated' do
1155
+ expect{ @pubnub.publish(
1156
+ message: { text: 'sometext' },
1157
+ channel: 'ruby_demo_channel',
1158
+ callback: @callback,
1159
+ http_sync: true,
1160
+ meta: 123
1161
+ ) }.to raise_error(Pubnub::ArgumentError)
1162
+ end
1163
+ end
1117
1164
  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: 3.8.2
4
+ version: 3.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PubNub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-17 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -362,6 +362,7 @@ files:
362
362
  - fixtures/vcr_cassettes/integration/history/history-ssl-parameter-valid-200-sync.yml
363
363
  - fixtures/vcr_cassettes/integration/history/history-ssl-parameter-valid-non-200-async.yml
364
364
  - fixtures/vcr_cassettes/integration/history/history-ssl-parameter-valid-non-200-sync.yml
365
+ - fixtures/vcr_cassettes/integration/history/include_token.yml
365
366
  - fixtures/vcr_cassettes/integration/leave/leave-nonssl-block-invalid-200-async.yml
366
367
  - fixtures/vcr_cassettes/integration/leave/leave-nonssl-block-invalid-200-sync.yml
367
368
  - fixtures/vcr_cassettes/integration/leave/leave-nonssl-block-invalid-non-200-async.yml
@@ -492,6 +493,7 @@ files:
492
493
  - fixtures/vcr_cassettes/integration/publish/publish-https-auth_key-non200-valid.yml
493
494
  - fixtures/vcr_cassettes/integration/publish/publish-https-non200-invalid.yml
494
495
  - fixtures/vcr_cassettes/integration/publish/publish-https-non200-valid.yml
496
+ - fixtures/vcr_cassettes/integration/publish/publish-meta.yml
495
497
  - fixtures/vcr_cassettes/integration/publish/publish-plain-array-of-hashes.yml
496
498
  - fixtures/vcr_cassettes/integration/revoke/revoke-application-level.yml
497
499
  - fixtures/vcr_cassettes/integration/revoke/revoke-nonssl-block-invalid-200-async.yml
@@ -1849,7 +1851,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1849
1851
  version: '0'
1850
1852
  requirements: []
1851
1853
  rubyforge_project:
1852
- rubygems_version: 2.5.1
1854
+ rubygems_version: 2.5.2
1853
1855
  signing_key:
1854
1856
  specification_version: 4
1855
1857
  summary: PubNub Official Ruby gem.