pubnub 3.4 → 3.4.1
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 +3 -0
- data/README.md +7 -2
- data/lib/pubnub.rb +1 -2
- data/lib/pubnub/client.rb +17 -9
- data/lib/pubnub/configuration.rb +1 -1
- data/lib/pubnub/uuid.rb +10 -0
- data/lib/pubnub/version.rb +3 -0
- data/pubnub.gemspec +1 -2
- data/spec/lib/subscribe_timeout_spec.rb +65 -0
- metadata +6 -16
- data/lib/version.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d36c99c090137e15da39515489f5487e3d07c028
|
4
|
+
data.tar.gz: a49d8b178508761e055c4105665e265fded9f1f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c25b97f6ee76a24ecb39a314f0499051d650ebf6f61a692291c15213190bca473a2cd3d994c9e551844593c791b292edd499c4f634b4ef4dca21ca4f7dadf20
|
7
|
+
data.tar.gz: ed0f70d2bdf78eb0091df1d61de33cdea41d46c2782d7a2c8e512f8829691dfbc990abb5a8edc43927948d3b8db0ba86fb23d32147e07a05c70102f8565b751f
|
data/CHANGELOG
ADDED
data/README.md
CHANGED
@@ -37,6 +37,10 @@ require 'pubnub'
|
|
37
37
|
#### Init and instantiate a new PubNub instance
|
38
38
|
|
39
39
|
```ruby
|
40
|
+
|
41
|
+
# If you wish to override the default logger, create one and pass it in.
|
42
|
+
my_logger = Logger.new(STDOUT)
|
43
|
+
|
40
44
|
pubnub = Pubnub.new(
|
41
45
|
:subscribe_key => 'demo',
|
42
46
|
:publish_key => 'demo',
|
@@ -46,7 +50,8 @@ pubnub = Pubnub.new(
|
|
46
50
|
},
|
47
51
|
:connect_callback => lambda { |msg|
|
48
52
|
puts "CONNECTED: #{msg.inspect}"
|
49
|
-
}
|
53
|
+
},
|
54
|
+
:logger => my_logger
|
50
55
|
)
|
51
56
|
```
|
52
57
|
|
@@ -170,7 +175,7 @@ When publishing, send a string, number, array, or hash. PubNub automatically ser
|
|
170
175
|
@my_callback = lambda { |envelope| puts(envelope.msg) }
|
171
176
|
|
172
177
|
pubnub.publish(
|
173
|
-
:channel => "hello_world"
|
178
|
+
:channel => "hello_world",
|
174
179
|
:message => "hi",
|
175
180
|
:callback => @my_callback
|
176
181
|
)
|
data/lib/pubnub.rb
CHANGED
@@ -9,7 +9,6 @@
|
|
9
9
|
## PubNub 3.4 Real-time Push Cloud API
|
10
10
|
## -----------------------------------
|
11
11
|
|
12
|
-
require 'uuid'
|
13
12
|
require 'json'
|
14
13
|
require 'base64'
|
15
14
|
require 'open-uri'
|
@@ -18,7 +17,7 @@ require 'openssl'
|
|
18
17
|
require 'eventmachine'
|
19
18
|
require 'em-http-request'
|
20
19
|
|
21
|
-
require 'version.rb'
|
20
|
+
require 'pubnub/version.rb'
|
22
21
|
|
23
22
|
require 'pubnub/client.rb'
|
24
23
|
require 'pubnub/request.rb'
|
data/lib/pubnub/client.rb
CHANGED
@@ -4,6 +4,7 @@ require 'em-http-request'
|
|
4
4
|
require 'httparty'
|
5
5
|
require 'persistent_httparty'
|
6
6
|
require 'timeout'
|
7
|
+
require 'pubnub/uuid'
|
7
8
|
|
8
9
|
module Pubnub
|
9
10
|
class PubNubHTTParty
|
@@ -59,7 +60,7 @@ module Pubnub
|
|
59
60
|
@timetoken = options[:timetoken]
|
60
61
|
@session_uuid = options[:uuid] || options[:session_uuid] || UUID.new.generate
|
61
62
|
|
62
|
-
|
63
|
+
@history_count = options[:count]
|
63
64
|
@history_start = options[:start]
|
64
65
|
@history_end = options[:end]
|
65
66
|
@history_reverse = options[:reverse]
|
@@ -232,7 +233,6 @@ module Pubnub
|
|
232
233
|
@subscription_request.channel = get_channels_for_subscription.join(',')
|
233
234
|
|
234
235
|
@subscription_running = EM.add_periodic_timer(PERIODIC_TIMER) do
|
235
|
-
|
236
236
|
unless @wait_for_response || get_channels_for_subscription.empty?
|
237
237
|
@wait_for_response = true
|
238
238
|
$log.debug 'SETTING CHANNELS'
|
@@ -242,8 +242,8 @@ module Pubnub
|
|
242
242
|
|
243
243
|
http.callback do
|
244
244
|
$log.debug 'GOT SUBSCRIBE RESPONSE'
|
245
|
-
@wait_for_response = false
|
246
245
|
if http.response_header.status.to_i == 200
|
246
|
+
$log.debug 'STATUS 200'
|
247
247
|
if is_valid_json?(http.response)
|
248
248
|
$log.debug 'GOT VALID JSON'
|
249
249
|
@subscription_request.handle_response(http)
|
@@ -273,10 +273,20 @@ module Pubnub
|
|
273
273
|
end
|
274
274
|
|
275
275
|
end
|
276
|
+
|
277
|
+
@wait_for_response = false
|
276
278
|
end
|
279
|
+
|
277
280
|
http.errback do
|
278
281
|
$log.error 'GOT SUBSCRIBE ERROR'
|
279
|
-
@error_callback.call
|
282
|
+
@error_callback.call Pubnub::Response.new(
|
283
|
+
:error_init => true,
|
284
|
+
:message => [0, http.error].to_json,
|
285
|
+
:response => [0, http.error].to_json
|
286
|
+
)
|
287
|
+
$log.error 'CALLED ERROR CALLBACK'
|
288
|
+
|
289
|
+
@wait_for_response = false
|
280
290
|
end
|
281
291
|
end
|
282
292
|
end unless @subscription_running
|
@@ -451,11 +461,9 @@ module Pubnub
|
|
451
461
|
unless @subscribe_connection
|
452
462
|
@subscribe_connection = EM::HttpRequest.new(request.origin, :connect_timeout => 370, :inactivity_timeout => 370)
|
453
463
|
connection = @subscribe_connection.get :path => '/time/0', :keepalive => true, :query => request.query
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
end
|
458
|
-
#end
|
464
|
+
connection.callback do
|
465
|
+
@connect_callback.call 'ASYNC SUBSCRIBE CONNECTION'
|
466
|
+
end
|
459
467
|
end
|
460
468
|
|
461
469
|
@subscribe_connection.get :path => request.path, :query => request.query, :keepalive => true
|
data/lib/pubnub/configuration.rb
CHANGED
data/lib/pubnub/uuid.rb
ADDED
data/pubnub.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'pubnub'
|
5
|
-
s.version = '3.4'
|
5
|
+
s.version = '3.4.1'
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ['PubNub']
|
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency 'httparty'
|
21
21
|
s.add_dependency 'persistent_httparty'
|
22
22
|
s.add_dependency 'em-http-request'
|
23
|
-
s.add_dependency 'uuid', '~> 2.3.5'
|
24
23
|
s.add_dependency 'json'
|
25
24
|
|
26
25
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe '#subscribe' do
|
4
|
+
context 'got timeout' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@after_callback = false
|
8
|
+
@after_error_callback = false
|
9
|
+
@output = StringIO.new
|
10
|
+
@error_output = StringIO.new
|
11
|
+
@msg_output = StringIO.new
|
12
|
+
|
13
|
+
@callback = lambda { |envelope|
|
14
|
+
$log.debug 'FIRE CALLBACK'
|
15
|
+
@after_callback = true
|
16
|
+
@output.write envelope.response
|
17
|
+
@msg_output.write envelope.msg
|
18
|
+
EM.stop if EM.reactor_running?
|
19
|
+
}
|
20
|
+
|
21
|
+
@error_callback = lambda { |envelope|
|
22
|
+
if envelope.is_a? Array
|
23
|
+
$log.error envelope
|
24
|
+
else
|
25
|
+
@error_output.write envelope.response
|
26
|
+
end
|
27
|
+
@after_error_callback = true
|
28
|
+
}
|
29
|
+
|
30
|
+
@pn = Pubnub.new(:publish_key => :demo, :subscribe_key => :demo, :error_callback => @error_callback)
|
31
|
+
@pn.session_uuid = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
stub_request(:get, /http[s]?:\/\/pubsub.pubnub.com\/subscribe\/demo\/demo\/0\/\d+/).
|
36
|
+
to_timeout.
|
37
|
+
to_return(lambda { |request|
|
38
|
+
{
|
39
|
+
:body => [[{"text" => "hey"}],"#{/\d+$/.match(request.uri.path).to_s.to_i + 1}"].to_json,
|
40
|
+
:status => '200',
|
41
|
+
:headers => {
|
42
|
+
'Content-Type' => 'text/javascript; charset="UTF-8"'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
})
|
46
|
+
|
47
|
+
stub_request(:get, /http[s]?:\/\/pubsub.pubnub.com\/time\/0/).
|
48
|
+
to_return(
|
49
|
+
{
|
50
|
+
:body => '[13804562752311765]',
|
51
|
+
:status => 200,
|
52
|
+
:headers => {
|
53
|
+
'Content-Type' => 'text/javascript; charset="UTF-8"'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'raises error callback with proper message and continue' do
|
60
|
+
#binding.pry
|
61
|
+
@pn.subscribe(:channel => :demo, :callback => @callback)
|
62
|
+
until @after_callback do end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: uuid
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.3.5
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.3.5
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: json
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,6 +91,7 @@ files:
|
|
105
91
|
- .yardoc/object_types
|
106
92
|
- .yardoc/objects/root.dat
|
107
93
|
- .yardoc/proxy_types
|
94
|
+
- CHANGELOG
|
108
95
|
- LICENSE
|
109
96
|
- README.md
|
110
97
|
- Rakefile
|
@@ -217,8 +204,9 @@ files:
|
|
217
204
|
- lib/pubnub/request.rb
|
218
205
|
- lib/pubnub/response.rb
|
219
206
|
- lib/pubnub/subscription.rb
|
207
|
+
- lib/pubnub/uuid.rb
|
208
|
+
- lib/pubnub/version.rb
|
220
209
|
- lib/tasks/examples.rake
|
221
|
-
- lib/version.rb
|
222
210
|
- pubnub.gemspec
|
223
211
|
- spec/lib/client_spec.rb
|
224
212
|
- spec/lib/crypto_spec.rb
|
@@ -228,6 +216,7 @@ files:
|
|
228
216
|
- spec/lib/pubnub_spec.rb
|
229
217
|
- spec/lib/request_spec.rb
|
230
218
|
- spec/lib/subscribe_integration_spec.rb
|
219
|
+
- spec/lib/subscribe_timeout_spec.rb
|
231
220
|
- spec/lib/time_integration_spec.rb
|
232
221
|
- spec/spec_helper.rb
|
233
222
|
homepage: http://github.com/pubnub/ruby
|
@@ -255,3 +244,4 @@ signing_key:
|
|
255
244
|
specification_version: 4
|
256
245
|
summary: PubNub Official Ruby gem
|
257
246
|
test_files: []
|
247
|
+
has_rdoc:
|
data/lib/version.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
PUBNUB_VERSION = '3.4'
|