pubnub 0.1.12 → 3.3.0.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.
- data/lib/pubnub.rb +298 -235
- data/lib/pubnub_crypto.rb +53 -142
- data/lib/pubnub_deferrable.rb +37 -0
- data/lib/pubnub_request.rb +287 -0
- metadata +90 -71
- data/README +0 -83
- data/examples/history_example.rb +0 -41
- data/examples/publish_example.rb +0 -69
- data/examples/subscribe_example.rb +0 -43
- data/examples/uuid_example.rb +0 -15
- data/tests/unit_test.rb +0 -88
metadata
CHANGED
@@ -1,94 +1,113 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 12
|
9
|
-
version: 0.1.12
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.3.0.1
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
7
|
+
authors:
|
8
|
+
- PubNub
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: eventmachine
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.12.9
|
32
38
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: json
|
36
39
|
prerelease: false
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.12.9
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: uuid
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.3.5
|
44
54
|
type: :runtime
|
45
|
-
|
46
|
-
|
47
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.3.5
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yajl-ruby
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Ruby anywhere in the world in 250ms with PubNub!
|
79
|
+
email: support@pubnub.com
|
48
80
|
executables: []
|
49
|
-
|
50
81
|
extensions: []
|
51
|
-
|
52
|
-
|
53
|
-
- README
|
54
|
-
files:
|
55
|
-
- examples/history_example.rb
|
56
|
-
- examples/publish_example.rb
|
57
|
-
- examples/subscribe_example.rb
|
58
|
-
- examples/uuid_example.rb
|
82
|
+
extra_rdoc_files: []
|
83
|
+
files:
|
59
84
|
- lib/pubnub.rb
|
60
85
|
- lib/pubnub_crypto.rb
|
61
|
-
-
|
62
|
-
-
|
63
|
-
has_rdoc: true
|
86
|
+
- lib/pubnub_deferrable.rb
|
87
|
+
- lib/pubnub_request.rb
|
64
88
|
homepage: http://github.com/pubnub/pubnub-api
|
65
|
-
licenses:
|
89
|
+
licenses:
|
66
90
|
- MIT
|
67
91
|
post_install_message:
|
68
92
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
93
|
+
require_paths:
|
71
94
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
- 0
|
85
|
-
version: "0"
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
86
107
|
requirements: []
|
87
|
-
|
88
108
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.
|
109
|
+
rubygems_version: 1.8.24
|
90
110
|
signing_key:
|
91
111
|
specification_version: 3
|
92
|
-
summary: PubNub Official
|
112
|
+
summary: PubNub Official Ruby gem
|
93
113
|
test_files: []
|
94
|
-
|
data/README
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
Pubnub - http://github/pubnub/pubnub-api
|
2
|
-
@poptartinc on Twitter, @poptart on Github
|
3
|
-
|
4
|
-
## ------------------------------------------
|
5
|
-
## PubNub 3.1 Real-time Cloud Push API - RUBY
|
6
|
-
## ------------------------------------------
|
7
|
-
##
|
8
|
-
## www.pubnub.com - PubNub Real-time Push Service in the Cloud.
|
9
|
-
## http://www.pubnub.com/blog/ruby-push-api
|
10
|
-
##
|
11
|
-
## PubNub is a Massively Scalable Real-time Service for Web and Mobile Games.
|
12
|
-
## This is a cloud-based service for broadcasting Real-time messages
|
13
|
-
## to thousands of web and mobile clients simultaneously.
|
14
|
-
|
15
|
-
## -------------
|
16
|
-
## Ruby Push API
|
17
|
-
## -------------
|
18
|
-
pubnub = Pubnub.new(
|
19
|
-
"demo", ## PUBLISH_KEY
|
20
|
-
"demo", ## SUBSCRIBE_KEY
|
21
|
-
"demo", ## SECRET_KEY
|
22
|
-
"", ## CIPHER_KEY (Cipher key is Optional)
|
23
|
-
false ## SSL_ON?
|
24
|
-
)
|
25
|
-
|
26
|
-
# -------
|
27
|
-
# PUBLISH STRING MESSAGE
|
28
|
-
# -------
|
29
|
-
# Send Message
|
30
|
-
info = pubnub.publish({
|
31
|
-
'channel' => 'hello_world',
|
32
|
-
'message' => 'hey what is up?'
|
33
|
-
})
|
34
|
-
puts(info)
|
35
|
-
|
36
|
-
# -------
|
37
|
-
# PUBLISH ARRAY OF MESSAGES
|
38
|
-
# -------
|
39
|
-
# Send Message
|
40
|
-
info = pubnub.publish({
|
41
|
-
'channel' => 'hello_world',
|
42
|
-
'message' => { ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] }
|
43
|
-
})
|
44
|
-
puts(info)
|
45
|
-
|
46
|
-
# -------
|
47
|
-
# PUBLISH OBJECT OF STRING MESSAGE
|
48
|
-
# -------
|
49
|
-
# Send Message
|
50
|
-
info = pubnub.publish({
|
51
|
-
'channel' => 'hello_world',
|
52
|
-
'message' => { 'text' => 'some text data' }
|
53
|
-
})
|
54
|
-
puts(info)
|
55
|
-
|
56
|
-
# ---------
|
57
|
-
# SUBSCRIBE
|
58
|
-
# ---------
|
59
|
-
# Listen for Messages *NON-BLOCKING*
|
60
|
-
pubnub.subscribe({
|
61
|
-
'channel' => 'hello_world',
|
62
|
-
'callback' => lambda do |message|
|
63
|
-
puts(message) ## print message
|
64
|
-
return true ## keep listening?
|
65
|
-
end
|
66
|
-
})
|
67
|
-
|
68
|
-
# -------
|
69
|
-
# HISTORY
|
70
|
-
# -------
|
71
|
-
# Load Previously Published Messages
|
72
|
-
messages = pubnub.history({
|
73
|
-
'channel' => 'hello_world',
|
74
|
-
'limit' => 10
|
75
|
-
})
|
76
|
-
puts(messages)
|
77
|
-
|
78
|
-
# -------
|
79
|
-
# UUID
|
80
|
-
# -------
|
81
|
-
# Generate UUID
|
82
|
-
uuid = pubnub.UUID()
|
83
|
-
puts(uuid)
|
data/examples/history_example.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
## -----------------------------------
|
2
|
-
## PubNub Ruby API History Example
|
3
|
-
## -----------------------------------
|
4
|
-
|
5
|
-
## including required libraries
|
6
|
-
require 'rubygems'
|
7
|
-
require 'pubnub'
|
8
|
-
|
9
|
-
## declaring publish_key, subscribe_key, secret_key, cipher_key and ssl flag (Cipher key is Optional)
|
10
|
-
publish_key = 'demo'
|
11
|
-
subscribe_key = 'demo'
|
12
|
-
secret_key = 'demo'
|
13
|
-
cipher_key = '' # (Cipher key is Optional)
|
14
|
-
ssl_on = false
|
15
|
-
|
16
|
-
## Print usage if missing info.
|
17
|
-
if !subscribe_key
|
18
|
-
puts('
|
19
|
-
Get API Keys at http://www.pubnub.com/account
|
20
|
-
==============
|
21
|
-
EXAMPLE USAGE:
|
22
|
-
==============
|
23
|
-
ruby history-example.rb PUBLISH-KEY SUBSCRIBE-KEY SSL-ON
|
24
|
-
ruby history-example.rb demo demo true
|
25
|
-
')
|
26
|
-
end
|
27
|
-
|
28
|
-
## Create Pubnub Client API (INITIALIZATION)
|
29
|
-
puts('Initializing new Pubnub state')
|
30
|
-
pubnub = Pubnub.new(publish_key,subscribe_key,secret_key,cipher_key,ssl_on)
|
31
|
-
|
32
|
-
## Request Past Publishes (HISTORY)
|
33
|
-
puts('Requesting History with history() Function')
|
34
|
-
pubnub.history({
|
35
|
-
'channel' => 'hello_world',
|
36
|
-
'limit' => 5,
|
37
|
-
'callback' => lambda do |message|
|
38
|
-
puts(message)
|
39
|
-
end
|
40
|
-
})
|
41
|
-
#puts(message)
|
data/examples/publish_example.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
## -----------------------------------
|
2
|
-
## PubNub Ruby API Publish Example
|
3
|
-
## -----------------------------------
|
4
|
-
|
5
|
-
## including required libraries
|
6
|
-
require 'rubygems'
|
7
|
-
require 'pubnub'
|
8
|
-
|
9
|
-
## declaring publish_key, subscribe_key, secret_key, cipher_key, channel, ssl flag, messages (Cipher key is Optional)
|
10
|
-
publish_key = 'demo'
|
11
|
-
subscribe_key = 'demo'
|
12
|
-
secret_key = 'demo'
|
13
|
-
cipher_key = '' # (Cipher key is Optional)
|
14
|
-
ssl_on = false
|
15
|
-
channel = 'hello_world'
|
16
|
-
|
17
|
-
strMessage = "Hi. (顶顅Ȓ)"
|
18
|
-
arrMessage = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
|
19
|
-
objMessage = {"Name"=>"John","Age"=>"23"}
|
20
|
-
|
21
|
-
## Print usage if missing info.
|
22
|
-
if !strMessage && arrMessage && objMessage
|
23
|
-
puts('
|
24
|
-
Get API Keys at http://www.pubnub.com/account
|
25
|
-
==============
|
26
|
-
EXAMPLE USAGE:
|
27
|
-
==============
|
28
|
-
ruby publish-example.rb PUB-KEY SUB-KEY SECRET-KEY "message text" SSL-ON
|
29
|
-
ruby publish-example.rb demo demo "demo" "hey what is up?" true
|
30
|
-
')
|
31
|
-
exit()
|
32
|
-
end
|
33
|
-
|
34
|
-
## Pubnub state initialization (INITIALIZATION)
|
35
|
-
puts('Initializing new Pubnub state')
|
36
|
-
pubnub = Pubnub.new(publish_key,subscribe_key,secret_key,cipher_key,ssl_on)
|
37
|
-
|
38
|
-
## Send Message (PUBLISH) -- String
|
39
|
-
puts("\nSending message in String format with publish() Function")
|
40
|
-
info = pubnub.publish({
|
41
|
-
'channel' => channel,
|
42
|
-
'message' => strMessage,
|
43
|
-
'callback' => lambda do |message|
|
44
|
-
puts(message)
|
45
|
-
end
|
46
|
-
})
|
47
|
-
puts(info)
|
48
|
-
|
49
|
-
## Send Message (PUBLISH) -- Array
|
50
|
-
puts("\nSending message in Array format with publish() Function")
|
51
|
-
pubnub.publish({
|
52
|
-
'channel' => channel,
|
53
|
-
'message' => arrMessage,
|
54
|
-
'callback' => lambda do |message|
|
55
|
-
puts(message)
|
56
|
-
end
|
57
|
-
})
|
58
|
-
#puts(info)
|
59
|
-
|
60
|
-
## Send Message (PUBLISH) -- Object (Dictionary)
|
61
|
-
puts("\nSending message in Dictionary Object format with publish() Function")
|
62
|
-
pubnub.publish({
|
63
|
-
'channel' => channel,
|
64
|
-
'message' => objMessage,
|
65
|
-
'callback' => lambda do |message|
|
66
|
-
puts(message)
|
67
|
-
end
|
68
|
-
})
|
69
|
-
#puts(info)
|
@@ -1,43 +0,0 @@
|
|
1
|
-
## -----------------------------------
|
2
|
-
## PubNub Ruby API Subscribe Example
|
3
|
-
## -----------------------------------
|
4
|
-
|
5
|
-
## including required libraries
|
6
|
-
require 'rubygems'
|
7
|
-
require 'pubnub'
|
8
|
-
|
9
|
-
## declaring publish_key, subscribe_key, secret_key, cipher_key, ssl flag (Cipher key is Optional)
|
10
|
-
publish_key = 'demo'
|
11
|
-
subscribe_key = 'demo'
|
12
|
-
secret_key = 'demo'
|
13
|
-
cipher_key = '' # (Cipher key is Optional)
|
14
|
-
ssl_on = false
|
15
|
-
channel = 'hello_world'
|
16
|
-
|
17
|
-
## Print usage if missing info.
|
18
|
-
if !subscribe_key
|
19
|
-
puts('
|
20
|
-
Get API Keys at http://www.pubnub.com/account
|
21
|
-
==============
|
22
|
-
EXAMPLE USAGE:
|
23
|
-
==============
|
24
|
-
ruby subscribe-example.rb PUBLISH-KEY SUBSCRIBE-KEY SSL-ON
|
25
|
-
ruby subscribe-example.rb demo demo true
|
26
|
-
')
|
27
|
-
exit()
|
28
|
-
end
|
29
|
-
|
30
|
-
## Create Pubnub Client API (INITIALIZATION)
|
31
|
-
puts('Initializing new Pubnub state')
|
32
|
-
pubnub = Pubnub.new(publish_key,subscribe_key,secret_key,cipher_key,ssl_on)
|
33
|
-
|
34
|
-
## Listen for Messages (SUBSCRIBE)
|
35
|
-
puts('Listening for new messages with subscribe() Function')
|
36
|
-
puts('Press CTRL+C to quit.')
|
37
|
-
pubnub.subscribe({
|
38
|
-
'channel' => channel,
|
39
|
-
'callback' => lambda do |message|
|
40
|
-
puts(message) ## print message
|
41
|
-
return true ## keep listening?
|
42
|
-
end
|
43
|
-
})
|
data/examples/uuid_example.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
## -----------------------------------
|
2
|
-
## PubNub Ruby API UUID Example
|
3
|
-
## -----------------------------------
|
4
|
-
|
5
|
-
## including required libraries
|
6
|
-
require 'rubygems'
|
7
|
-
require 'pubnub'
|
8
|
-
|
9
|
-
## Generating UUID String
|
10
|
-
pubnub=Pubnub.new("","","","",false)
|
11
|
-
|
12
|
-
## calling function for UUID generation
|
13
|
-
puts('Generating UUID String with UUID() Function')
|
14
|
-
uuid=pubnub.UUID()
|
15
|
-
puts('UUID: '+uuid)
|
data/tests/unit_test.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
## www.pubnub.com - PubNub realtime push service in the cloud.
|
2
|
-
## http://www.pubnub.com/blog/ruby-push-api - Ruby Push API Blog
|
3
|
-
|
4
|
-
## PubNub Real Time Push APIs and Notifications Framework
|
5
|
-
## Copyright (c) 2010 Stephen Blum
|
6
|
-
## http://www.pubnub.com/
|
7
|
-
|
8
|
-
## -----------------------------------
|
9
|
-
## PubNub 3.1 Real-time Push Cloud API
|
10
|
-
## -----------------------------------
|
11
|
-
|
12
|
-
## including required libraries
|
13
|
-
require 'rubygems'
|
14
|
-
require 'pubnub'
|
15
|
-
|
16
|
-
## declaring publish_key, subscribe_key, secret_key, cipher_key, message, ssl_on (Cipher key is Optional)
|
17
|
-
publish_key = ARGV[0] || 'demo'
|
18
|
-
subscribe_key = ARGV[1] || 'demo'
|
19
|
-
secret_key = ARGV[2] || 'demo'
|
20
|
-
cipher_key = ARGV[3] || '' # (Cipher key is Optional)
|
21
|
-
ssl_on = false
|
22
|
-
channel = 'hello_world'
|
23
|
-
message = 'Hi. (顶顅Ȓ)'
|
24
|
-
|
25
|
-
## ---------------------------------------------------------------------------
|
26
|
-
## Create Pubnub Client API (INITIALIZATION)
|
27
|
-
## ---------------------------------------------------------------------------
|
28
|
-
puts('Initializing new Pubnub state')
|
29
|
-
pubnub = Pubnub.new( publish_key, subscribe_key, secret_key,cipher_key, ssl_on )
|
30
|
-
|
31
|
-
## ---------------------------------------------------------------------------
|
32
|
-
## Unit Test Function
|
33
|
-
## ---------------------------------------------------------------------------
|
34
|
-
def test( trial, name )
|
35
|
-
trial ? puts('PASS: ' + name) : puts('FAIL: ' + name)
|
36
|
-
end
|
37
|
-
|
38
|
-
## ---------------------------------------------------------------------------
|
39
|
-
## UUID generation
|
40
|
-
## ---------------------------------------------------------------------------
|
41
|
-
uuid = pubnub.UUID()
|
42
|
-
test( uuid.length > 0, 'PubNub Client API UUID: ' + uuid )
|
43
|
-
|
44
|
-
## ---------------------------------------------------------------------------
|
45
|
-
## PubNub Server Time
|
46
|
-
## ---------------------------------------------------------------------------
|
47
|
-
pubnub.time({'callback' => lambda do |message|
|
48
|
-
print 'PubNub Server Time: ', message ## print message
|
49
|
-
end
|
50
|
-
})
|
51
|
-
|
52
|
-
## ---------------------------------------------------------------------------
|
53
|
-
## PUBLISH
|
54
|
-
## ---------------------------------------------------------------------------
|
55
|
-
pubnub.publish({
|
56
|
-
'channel' => channel,
|
57
|
-
'message' => message,
|
58
|
-
'callback' => lambda do |message|
|
59
|
-
puts(message)
|
60
|
-
end
|
61
|
-
})
|
62
|
-
#test( pubish_success[0] == 1, 'Publish First Message Success' )
|
63
|
-
|
64
|
-
## ---------------------------------------------------------------------------
|
65
|
-
## HISTORY
|
66
|
-
## ---------------------------------------------------------------------------
|
67
|
-
pubnub.history({
|
68
|
-
'channel' => channel,
|
69
|
-
'limit' => 5,
|
70
|
-
'callback' => lambda do |message|
|
71
|
-
puts(message)
|
72
|
-
end
|
73
|
-
})
|
74
|
-
#puts(history)
|
75
|
-
#test( history.length >= 1, 'Display History' )
|
76
|
-
|
77
|
-
## ---------------------------------------------------------------------------
|
78
|
-
## Subscribe
|
79
|
-
## ---------------------------------------------------------------------------
|
80
|
-
puts('Listening for new messages with subscribe() Function')
|
81
|
-
puts('Press CTRL+C to quit.')
|
82
|
-
pubnub.subscribe({
|
83
|
-
'channel' => channel,
|
84
|
-
'callback' => lambda do |message|
|
85
|
-
puts(message) ## print message
|
86
|
-
return true ## keep listening?
|
87
|
-
end
|
88
|
-
})
|