pubnub 3.5.3 → 3.5.5
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/README.md +7 -3
- data/VERSION +1 -1
- data/examples/demo_console_new.rb +286 -0
- data/fixtures/vcr_cassettes/grant-application-level.yml +44 -0
- data/fixtures/vcr_cassettes/revoke-application-level.yml +44 -0
- data/lib/pubnub/client.rb +1 -1
- data/lib/pubnub/event.rb +10 -1
- data/lib/pubnub/events/subscribe.rb +1 -1
- data/lib/pubnub/pam.rb +1 -1
- data/lib/version.rb +1 -1
- data/pubnub.gemspec +2 -2
- data/spec/lib/integration/grant_spec.rb +11 -0
- data/spec/lib/integration/revoke_spec.rb +11 -0
- data/spec/lib/subscribe_event.rb +16 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26b4f23e927cf9a251f0ee9448b7a79989671927
|
4
|
+
data.tar.gz: 7e0bdee56ade94ffad6f9fa31f2c45cabe005031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d5c25706f7167c8f1283a704d33c307c7e6c772b09aff4e50d703b5e7594e48717cd2feb3ff77ef27649c7c999cde13feae1e13c60c790d1b09ecaa70c04f82
|
7
|
+
data.tar.gz: 057dcc61a333dc3bab121fc5412671be742a77a78bc936770db868c87858036d43d66e90ac76562746e983935468b431f9d882e24c7dec16cd2a629b15fa4378
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# Please direct all Support Questions and Concerns to Support@PubNub.com
|
2
|
+
|
1
3
|
##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
|
2
4
|
##### http://www.pubnub.com/account
|
3
5
|
|
@@ -14,14 +16,14 @@ PubNub 3.5.0 is NOT compatible with earlier than 3.4 versions of Pubnub Ruby Cli
|
|
14
16
|
PubNub 3.5.0 is compatible with 3.4 version.
|
15
17
|
|
16
18
|
#### Asynchronous vs Synchronous Responses
|
17
|
-
Every event you will fire could be fired asynchronous
|
19
|
+
Every event you will fire could be fired asynchronous or synchonous just by passing
|
18
20
|
```ruby
|
19
21
|
:http_sync
|
20
22
|
```
|
21
23
|
set to true to that event. Asynchronous events will not block your main thread and will be fired withing new thread.
|
22
24
|
|
23
25
|
#### Message Handling: callback, block, return
|
24
|
-
|
26
|
+
Results are provided via block, callback, and return, depending on how you structure the call. Callback will be fired for every message that will event get in response. Synchornous events will return array of envelopes (if you passed callback to sychronous event it will be called too!).
|
25
27
|
|
26
28
|
### Code Examples
|
27
29
|
|
@@ -498,4 +500,6 @@ module Pubnub
|
|
498
500
|
end
|
499
501
|
|
500
502
|
Pubnub.start
|
501
|
-
```
|
503
|
+
```
|
504
|
+
|
505
|
+
# Please direct all Support Questions and Concerns to Support@PubNub.com
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.5.
|
1
|
+
3.5.5
|
@@ -0,0 +1,286 @@
|
|
1
|
+
require 'pubnub'
|
2
|
+
require 'awesome_print'
|
3
|
+
|
4
|
+
class String
|
5
|
+
def black; "\033[30m#{self}\033[0m" end
|
6
|
+
def red; "\033[31m#{self}\033[0m" end
|
7
|
+
def green; "\033[32m#{self}\033[0m" end
|
8
|
+
def brown; "\033[33m#{self}\033[0m" end
|
9
|
+
def blue; "\033[34m#{self}\033[0m" end
|
10
|
+
def magenta; "\033[35m#{self}\033[0m" end
|
11
|
+
def cyan; "\033[36m#{self}\033[0m" end
|
12
|
+
def gray; "\033[37m#{self}\033[0m" end
|
13
|
+
def bg_black; "\033[40m#{self}\0330m" end
|
14
|
+
def bg_red; "\033[41m#{self}\033[0m" end
|
15
|
+
def bg_green; "\033[42m#{self}\033[0m" end
|
16
|
+
def bg_brown; "\033[43m#{self}\033[0m" end
|
17
|
+
def bg_blue; "\033[44m#{self}\033[0m" end
|
18
|
+
def bg_magenta; "\033[45m#{self}\033[0m" end
|
19
|
+
def bg_cyan; "\033[46m#{self}\033[0m" end
|
20
|
+
def bg_gray; "\033[47m#{self}\033[0m" end
|
21
|
+
def bold; "\033[1m#{self}\033[22m" end
|
22
|
+
def reverse_color; "\033[7m#{self}\033[27m" end
|
23
|
+
end
|
24
|
+
|
25
|
+
class DemoConsole
|
26
|
+
|
27
|
+
OPTIONS = {
|
28
|
+
:'1' => :Publish,
|
29
|
+
:'2' => :Subscribe,
|
30
|
+
:'3' => :Presence,
|
31
|
+
:'4' => :Leave,
|
32
|
+
:'5' => :History,
|
33
|
+
:'6' => :HereNow,
|
34
|
+
:'7' => :WhereNow,
|
35
|
+
:'8' => :State,
|
36
|
+
:'9' => :Heartbeat,
|
37
|
+
:'10' => :Time,
|
38
|
+
:'11' => :Audit,
|
39
|
+
:'12' => :Grant,
|
40
|
+
:'13' => :Revoke,
|
41
|
+
:A => :set_uuid,
|
42
|
+
:B => :set_auth_key,
|
43
|
+
:C => :show_state,
|
44
|
+
:D => :set_state,
|
45
|
+
:EXIT => :exit
|
46
|
+
}
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
|
50
|
+
welcome
|
51
|
+
|
52
|
+
keys_option = select_keys
|
53
|
+
|
54
|
+
case keys_option.to_s
|
55
|
+
when '1'
|
56
|
+
@origin = 'pubsub.pubnub.com'
|
57
|
+
@subscribe_key = 'demo-36'
|
58
|
+
@publish_key = 'demo-36'
|
59
|
+
@secret_key = nil
|
60
|
+
|
61
|
+
when '2'
|
62
|
+
@origin = 'pubsub.pubnub.com'
|
63
|
+
@subscribe_key = 'sub-c-a478dd2a-c33d-11e2-883f-02ee2ddab7fe'
|
64
|
+
@publish_key = 'pub-c-a2650a22-deb1-44f5-aa87-1517049411d5'
|
65
|
+
@secret_key = 'sec-c-YjFmNzYzMGMtYmI3NC00NzJkLTlkYzYtY2MwMzI4YTJhNDVh'
|
66
|
+
|
67
|
+
when '3'
|
68
|
+
puts `clear`
|
69
|
+
print_pubnub
|
70
|
+
puts 'Okey, now you have to provide me your data or accept default:'.green
|
71
|
+
print 'origin [pubsub.pubnub.com]: '.white
|
72
|
+
@origin = gets.chomp!
|
73
|
+
print 'subscribe_key [demo-36]: '.white
|
74
|
+
@subscribe_key = gets.chomp!
|
75
|
+
print 'publish_key [demo-36]: '.white
|
76
|
+
@publish_key = gets.chomp!
|
77
|
+
print 'secret_key (nil by default): '.white
|
78
|
+
@secret_key = gets.chomp!
|
79
|
+
|
80
|
+
@origin = 'pubsub.pubnub.com' if @origin.blank?
|
81
|
+
@subscribe_key = 'demo-36' if @subscribe_key.blank?
|
82
|
+
@publish_key = 'demo-36' if @publish_key.blank?
|
83
|
+
@secret_key = nil if @secret_key.blank?
|
84
|
+
else
|
85
|
+
@origin = 'pubsub.pubnub.com'
|
86
|
+
@subscribe_key = 'demo-36'
|
87
|
+
@publish_key = 'demo-36'
|
88
|
+
@secret_key = nil
|
89
|
+
end
|
90
|
+
|
91
|
+
set_uuid_and_auth
|
92
|
+
|
93
|
+
@pubnub = Pubnub.new(
|
94
|
+
:subscribe_key => @subscribe_key,
|
95
|
+
:publish_key => @publish_key,
|
96
|
+
:secret_key => @secret_key,
|
97
|
+
:error_callback => method(:error_callback),
|
98
|
+
:auth_key => @auth_key
|
99
|
+
)
|
100
|
+
|
101
|
+
@pubnub.set_uuid(@uuid) unless @uuid.blank?
|
102
|
+
|
103
|
+
ap @pubnub
|
104
|
+
|
105
|
+
start_console
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
def welcome
|
110
|
+
puts `clear`
|
111
|
+
print_pubnub
|
112
|
+
puts 'Hello in interactive PubNub console!'.white
|
113
|
+
puts 'Feel free to play around with it!'.white
|
114
|
+
puts '--'
|
115
|
+
puts '[Hit ENTER to continue]'
|
116
|
+
gets
|
117
|
+
puts `clear`
|
118
|
+
end
|
119
|
+
|
120
|
+
def select_keys
|
121
|
+
print_pubnub
|
122
|
+
puts 'Before we start, you have to select demo app keys or add your own.'.green
|
123
|
+
print "\n"
|
124
|
+
puts '1. Basic demo keys -- You will be limited to standard events, no PAM features'.white
|
125
|
+
puts '2. PAM supprot keys -- You can check out all pubnub features, including PAM'.white
|
126
|
+
puts '3. Custom keys -- If you already have your own keys, you can set them here'.white
|
127
|
+
print "\n"
|
128
|
+
print 'Your choice: '.green
|
129
|
+
gets.chomp!
|
130
|
+
end
|
131
|
+
|
132
|
+
def set_uuid_and_auth
|
133
|
+
puts `clear`
|
134
|
+
print_pubnub
|
135
|
+
puts 'You can set up now your uuid and auth_key: '.green
|
136
|
+
print 'uuid [random_default]: '.white
|
137
|
+
@uuid = gets.chomp!
|
138
|
+
print 'auth_key (blank by default): '.white
|
139
|
+
@auth_key = gets.chomp
|
140
|
+
end
|
141
|
+
|
142
|
+
def set_uuid(uuid)
|
143
|
+
@pubnub.set_uuid(uuid)
|
144
|
+
end
|
145
|
+
|
146
|
+
def set_auth_key(auth_key)
|
147
|
+
@pubnub.set_auth_key(auth_key)
|
148
|
+
end
|
149
|
+
|
150
|
+
def start_console
|
151
|
+
puts `clear`
|
152
|
+
print_pubnub
|
153
|
+
puts 'CONSOLE STARTED!'.white.bg_green
|
154
|
+
exit = false
|
155
|
+
choice = false
|
156
|
+
until exit
|
157
|
+
until OPTIONS.keys.include?(choice)
|
158
|
+
puts 'Choose your next operation (type \'exit\' to exit):'.green
|
159
|
+
puts 'Events:'.green
|
160
|
+
puts '1. Publish'.white
|
161
|
+
puts '2. Subscribe'.white
|
162
|
+
puts '3. Presence'.white
|
163
|
+
puts '4. Leave (unsubscribe)'.white
|
164
|
+
puts '5. History'.white
|
165
|
+
puts '6. HereNow'.white
|
166
|
+
puts '7. WhereNow'.white
|
167
|
+
puts '8. State'.white
|
168
|
+
puts '9. Heartbeat'.white
|
169
|
+
puts '10. Time'.white
|
170
|
+
puts '11. Audit'.white if @secret_key
|
171
|
+
puts '12. Grant'.white if @secret_key
|
172
|
+
puts '13. Revoke'.white if @secret_key
|
173
|
+
puts "\nPubnub::Client interaction:".green
|
174
|
+
puts 'A. Set UUID'.white
|
175
|
+
puts 'B. Set auth_key'.white
|
176
|
+
puts 'C. Check state'.white
|
177
|
+
puts 'D. Set state'.white
|
178
|
+
print "\nYour choice: ".red
|
179
|
+
choice = gets.chomp!.to_s.upcase.to_sym
|
180
|
+
end
|
181
|
+
choice = OPTIONS[choice]
|
182
|
+
|
183
|
+
case choice
|
184
|
+
when :exit
|
185
|
+
exit = true
|
186
|
+
when :Publish
|
187
|
+
options = ask_about(:sync, :message, :channel)
|
188
|
+
@pubnub.publish(options)
|
189
|
+
when :Subscribe
|
190
|
+
options = ask_about(:sync, :channel)
|
191
|
+
@pubnub.subscribe(options)
|
192
|
+
when :Presence
|
193
|
+
options = ask_about(:sync, :channel)
|
194
|
+
@pubnub.presence(options)
|
195
|
+
when :Leave
|
196
|
+
options = ask_about(:sync, :channel)
|
197
|
+
@pubnub.leave(options)
|
198
|
+
when :History
|
199
|
+
options = ask_about(:sync, :channel, :reverse, :history_start, :history_end)
|
200
|
+
@pubnub.history(options)
|
201
|
+
when :HereNow
|
202
|
+
options = ask_about(:sync, :channel)
|
203
|
+
@pubnub.here_now(options)
|
204
|
+
when :WhereNow
|
205
|
+
options = ask_about(:sync, :uuid)
|
206
|
+
@pubnub.where_now(options)
|
207
|
+
when :State
|
208
|
+
options = ask_about(:sync, :channel, :uuid)
|
209
|
+
@pubnub.state(options)
|
210
|
+
when :Heartbeat
|
211
|
+
options = ask_about(:sync, :heartbeat)
|
212
|
+
@pubnub.heartbeat(options)
|
213
|
+
when :Time
|
214
|
+
options = ask_about(:sync)
|
215
|
+
@pubnub.time(options)
|
216
|
+
when :Audit
|
217
|
+
options = ask_about(:sync, :channel, :subscribe_key)
|
218
|
+
@pubnub.audit(options)
|
219
|
+
when :Grant
|
220
|
+
options = ask_about(:sync, :channel, :subscribe_key, :read, :write)
|
221
|
+
@pubnub.grant(options)
|
222
|
+
when :Revoke
|
223
|
+
options = ask_about(:sync, :channel, :subscribe_key, :read, :write)
|
224
|
+
@pubnub.revoke(options)
|
225
|
+
end
|
226
|
+
choice = nil
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# that adds callback method as :callback in options
|
231
|
+
def ask_about(*things)
|
232
|
+
options = {}
|
233
|
+
things.each do |thing|
|
234
|
+
case thing
|
235
|
+
when :sync
|
236
|
+
print 'Should event be async? '.white
|
237
|
+
options[:http_sync] = !acceptance
|
238
|
+
|
239
|
+
when :message
|
240
|
+
while options[:message].blank?
|
241
|
+
puts 'Write below message to publish:'.white
|
242
|
+
options[:message] = gets.chomp!
|
243
|
+
end
|
244
|
+
|
245
|
+
when :channel
|
246
|
+
while options[:channel].blank?
|
247
|
+
print 'Specify channel(s): '.white
|
248
|
+
options[:channel] = gets.chomp!
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
options.merge({:callback => method(:callback)})
|
253
|
+
end
|
254
|
+
|
255
|
+
def acceptance
|
256
|
+
%w(Y 1).include?(gets.chomp!.to_s.upcase)
|
257
|
+
end
|
258
|
+
|
259
|
+
def print_pubnub
|
260
|
+
puts '
|
261
|
+
__________ ___. _______ ___. ________ ________
|
262
|
+
\______ \__ _\_ |__ \ \ __ _\_ |__ \_____ \ / _____/
|
263
|
+
| ___/ | \ __ \ / | \| | \ __ \ _(__ < / __ \
|
264
|
+
| | | | / \_\ \/ | \ | / \_\ \ / \ \ |__\ \
|
265
|
+
|____| |____/|___ /\____|__ /____/|___ / /______ / /\ \_____ /
|
266
|
+
\/ \/ \/ \/ \/ \/
|
267
|
+
|
268
|
+
Pubnub 3.6.x Demo Console
|
269
|
+
'.red
|
270
|
+
end
|
271
|
+
|
272
|
+
def callback(envelope)
|
273
|
+
ap envelope
|
274
|
+
end
|
275
|
+
|
276
|
+
def connect_callback(data)
|
277
|
+
puts 'Connection established'.bg_green.white
|
278
|
+
end
|
279
|
+
|
280
|
+
def error_callback(error)
|
281
|
+
puts 'ERROR'.bg_red.white
|
282
|
+
ap error
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
DemoConsole.new
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://pubsub.pubnub.com/v1/auth/grant/sub-key/sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe?pnsdk=PubNub-Ruby/3.6.3&r=1&signature=kdDh/sFC3rSR%2Bt5AEymIc57d1velIr562V7usa5M4k0=×tamp=1234567890&ttl=1440&uuid=f0ac67ef-912f-4797-be67-a59745107306&w=1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Connection:
|
17
|
+
- keep-alive
|
18
|
+
Keep-Alive:
|
19
|
+
- 30
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Wed, 04 Jun 2014 19:52:01 GMT
|
27
|
+
Content-Type:
|
28
|
+
- text/javascript; charset=UTF-8
|
29
|
+
Content-Length:
|
30
|
+
- '174'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache, no-store, must-revalidate
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- '*'
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- GET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"status":200,"service":"Access Manager","message":"Success","payload":{"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","r":1,"ttl":1440,"w":1,"level":"subkey"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Wed, 04 Jun 2014 19:52:01 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://pubsub.pubnub.com/v1/auth/grant/sub-key/sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe?pnsdk=PubNub-Ruby/3.6.3&r=0&signature=kdDh/sFC3rSR%2Bt5AEymIc57d1velIr562V7usa5M4k0=×tamp=1234567890&ttl=1440&uuid=f0ac67ef-912f-4797-be67-a59745107306&w=0
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- '*/*'
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
Connection:
|
17
|
+
- keep-alive
|
18
|
+
Keep-Alive:
|
19
|
+
- 30
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Wed, 04 Jun 2014 19:52:01 GMT
|
27
|
+
Content-Type:
|
28
|
+
- text/javascript; charset=UTF-8
|
29
|
+
Content-Length:
|
30
|
+
- '174'
|
31
|
+
Connection:
|
32
|
+
- keep-alive
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache, no-store, must-revalidate
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- '*'
|
37
|
+
Access-Control-Allow-Methods:
|
38
|
+
- GET
|
39
|
+
body:
|
40
|
+
encoding: UTF-8
|
41
|
+
string: '{"status":200,"service":"Access Manager","message":"Success","payload":{"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","r":0,"ttl":1440,"w":0,"level":"subkey"}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Wed, 04 Jun 2014 19:52:01 GMT
|
44
|
+
recorded_with: VCR 2.9.2
|
data/lib/pubnub/client.rb
CHANGED
@@ -24,7 +24,7 @@ module Pubnub
|
|
24
24
|
end
|
25
25
|
|
26
26
|
EVENTS.each do |event_name|
|
27
|
-
define_method event_name do |params, &block|
|
27
|
+
define_method event_name do |params = {}, &block|
|
28
28
|
params[:callback] = block if params[:callback].nil?
|
29
29
|
event = Pubnub.const_get(classify_method(event_name)).new(params, self)
|
30
30
|
$logger.debug('Pubnub'){'Created event ' + event.class.to_s}
|
data/lib/pubnub/event.rb
CHANGED
@@ -272,10 +272,19 @@ module Pubnub
|
|
272
272
|
@channel.delete(channel)
|
273
273
|
$logger.error('Pubnub'){"Already subscribed to channel #{channel}, you have to leave that channel first"}
|
274
274
|
end
|
275
|
+
end
|
276
|
+
|
277
|
+
@channel.each do |channel|
|
275
278
|
$logger.debug('Pubnub'){'SubscribeEvent#add_channel | Adding channel'}
|
276
279
|
app.env[:subscriptions][@origin].add_channel(channel, app)
|
277
280
|
end
|
278
|
-
|
281
|
+
|
282
|
+
if @channel.empty?
|
283
|
+
false
|
284
|
+
else
|
285
|
+
app.start_respirator
|
286
|
+
true
|
287
|
+
end
|
279
288
|
end
|
280
289
|
|
281
290
|
if app.env[:subscriptions][@origin].nil?
|
@@ -23,7 +23,7 @@ module Pubnub
|
|
23
23
|
# Check channels
|
24
24
|
raise ArgumentError.new(:object => self, :message => 'Subscribe requires :channel or :channels argument') unless @channel
|
25
25
|
|
26
|
-
#
|
26
|
+
# Check callback
|
27
27
|
raise ArgumentError.new(:object => self, :message => 'Callback parameter is required while using async subscribe') if !@http_sync && @callback.blank?
|
28
28
|
|
29
29
|
end
|
data/lib/pubnub/pam.rb
CHANGED
@@ -26,7 +26,7 @@ module Pubnub
|
|
26
26
|
def parameters(app, signature = false)
|
27
27
|
params = super(app)
|
28
28
|
params.merge!({ :timestamp => @timestamp })
|
29
|
-
params.merge!({ :channel => @channel.first })
|
29
|
+
params.merge!({ :channel => @channel.first }) unless @channel.first.blank?
|
30
30
|
params.merge!({ :signature => signature(app) }) unless signature
|
31
31
|
params
|
32
32
|
end
|
data/lib/version.rb
CHANGED
data/pubnub.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'pubnub'
|
5
|
-
s.version = '3.5.
|
5
|
+
s.version = '3.5.5'
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ['PubNub']
|
9
|
-
s.date = '2014-
|
9
|
+
s.date = '2014-05-31'
|
10
10
|
s.description = 'Ruby anywhere in the world in 250ms with PubNub!'
|
11
11
|
s.email = 'support@pubnub.com'
|
12
12
|
s.files = `git ls-files`.split("\n")
|
@@ -33,6 +33,17 @@ describe "#grant" do
|
|
33
33
|
end
|
34
34
|
context "uses ssl" do
|
35
35
|
before(:each) { @ssl = true }
|
36
|
+
it "Generates valid url for application level" do
|
37
|
+
VCR.use_cassette("grant-application-level", :record => :none) do
|
38
|
+
@pn.grant(:http_sync => true, &@callback)
|
39
|
+
|
40
|
+
@after_callback.should eq true
|
41
|
+
@response_output.seek 0
|
42
|
+
@response_output.read.should eq '{"status":200,"service":"Access Manager","message":"Success","payload":{"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","r":1,"ttl":1440,"w":1,"level":"subkey"}}'
|
43
|
+
@message_output.seek 0
|
44
|
+
@message_output.read.should eq 'Success'
|
45
|
+
end
|
46
|
+
end
|
36
47
|
context "passess callback as block" do
|
37
48
|
context "gets valid json in response" do
|
38
49
|
context "gets status 200 in response" do
|
@@ -33,6 +33,17 @@ describe "#revoke" do
|
|
33
33
|
end
|
34
34
|
context "uses ssl" do
|
35
35
|
before(:each) { @ssl = true }
|
36
|
+
it "Generates valid url for application level" do
|
37
|
+
VCR.use_cassette("revoke-application-level", :record => :none) do
|
38
|
+
@pn.revoke(:http_sync => true, &@callback)
|
39
|
+
|
40
|
+
@after_callback.should eq true
|
41
|
+
@response_output.seek 0
|
42
|
+
@response_output.read.should eq '{"status":200,"service":"Access Manager","message":"Success","payload":{"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","r":0,"ttl":1440,"w":0,"level":"subkey"}}'
|
43
|
+
@message_output.seek 0
|
44
|
+
@message_output.read.should eq 'Success'
|
45
|
+
end
|
46
|
+
end
|
36
47
|
context "passess callback as block" do
|
37
48
|
context "gets valid json in response" do
|
38
49
|
context "gets status 200 in response" do
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Pubnub::SubscribeEvent' do
|
4
|
+
it 'doesnt include same channel to running subscription twice' do
|
5
|
+
@pn = Pubnub.new(:subscribe_key => 'demo-36', :publish_key => 'demo-36')
|
6
|
+
|
7
|
+
VCR.use_cassette("subscribe-event-include-test", :record => :all) do
|
8
|
+
@pn.subscribe(:http_sync => false, :channel => 'demo'){|e| }
|
9
|
+
@pn.subscribe(:http_sync => false, :channel => 'demo'){|e| }
|
10
|
+
|
11
|
+
eventually do
|
12
|
+
@pn.env[:subscriptions]['pubsub.pubnub.com'].get_channels.should eq ['demo']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
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.5.
|
4
|
+
version: 3.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- Rakefile
|
66
66
|
- VERSION
|
67
67
|
- examples/demo_console.rb
|
68
|
+
- examples/demo_console_new.rb
|
68
69
|
- examples/error_server.rb
|
69
70
|
- examples/pubnub_livestream/.gitignore
|
70
71
|
- examples/pubnub_livestream/Gemfile
|
@@ -223,6 +224,7 @@ files:
|
|
223
224
|
- fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-integer.yml
|
224
225
|
- fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-mix.yml
|
225
226
|
- fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-string.yml
|
227
|
+
- fixtures/vcr_cassettes/grant-application-level.yml
|
226
228
|
- fixtures/vcr_cassettes/grant-nonssl-block-invalid-200-async.yml
|
227
229
|
- fixtures/vcr_cassettes/grant-nonssl-block-invalid-200-sync.yml
|
228
230
|
- fixtures/vcr_cassettes/grant-nonssl-block-invalid-non-200-async.yml
|
@@ -487,6 +489,7 @@ files:
|
|
487
489
|
- fixtures/vcr_cassettes/publish-ssl-parameter-valid-200-sync.yml
|
488
490
|
- fixtures/vcr_cassettes/publish-ssl-parameter-valid-non-200-async.yml
|
489
491
|
- fixtures/vcr_cassettes/publish-ssl-parameter-valid-non-200-sync.yml
|
492
|
+
- fixtures/vcr_cassettes/revoke-application-level.yml
|
490
493
|
- fixtures/vcr_cassettes/revoke-nonssl-block-invalid-200-async.yml
|
491
494
|
- fixtures/vcr_cassettes/revoke-nonssl-block-invalid-200-sync.yml
|
492
495
|
- fixtures/vcr_cassettes/revoke-nonssl-block-invalid-non-200-async.yml
|
@@ -664,6 +667,7 @@ files:
|
|
664
667
|
- spec/lib/integration/time_spec.rb
|
665
668
|
- spec/lib/integration/v3_presence_spec.rb
|
666
669
|
- spec/lib/retry_logic_spec.rb
|
670
|
+
- spec/lib/subscribe_event.rb
|
667
671
|
- spec/spec_helper.rb
|
668
672
|
- spec/tools/pam-test-generator.rb
|
669
673
|
- spec/tools/test-generator.rb
|