celluloid_pubsub 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f553146c4281cefdba37767bc0c34aa7cac8fcb5
|
4
|
+
data.tar.gz: e847a478522bdca68ae7e700f816224a49564814
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a6abb2fa27acb9086e2f482b2fb78fdb197b14ffdc9037796e8b7b917e41963957b50565887072d8931a6dca0da5e791546e5c679ce2829433b48d1842db97
|
7
|
+
data.tar.gz: fc1c12cb83b08d4a82052f79624fd72c9492e0d446a5693bdb54a3de5fd246657c843757554d76a9869285f75ee77c6268ba8427747b307c1d9577c573656fe2
|
data/examples/simple_test.rb
CHANGED
@@ -7,7 +7,7 @@ class Subscriber
|
|
7
7
|
include Celluloid::Logger
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
|
10
|
+
@client = CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
|
11
11
|
ws.subscribe('test_channel') # this will execute after the connection is opened
|
12
12
|
end
|
13
13
|
end
|
@@ -29,16 +29,16 @@ class Publisher
|
|
29
29
|
include Celluloid::Logger
|
30
30
|
|
31
31
|
def initialize
|
32
|
-
@client =
|
32
|
+
@client = CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
|
33
33
|
ws.subscribe('test_channel2') # this will execute after the connection is opened
|
34
34
|
end
|
35
35
|
@client.publish('test_channel', 'data' => 'my_message') # the message needs to be a Hash
|
36
36
|
@client.publish('test_channel', 'data' => 'my_message')
|
37
37
|
@client.publish('test_channel', 'data' => 'my_message')
|
38
38
|
end
|
39
|
-
|
40
|
-
|
41
|
-
puts " publisher got #{message.inspect}"
|
39
|
+
|
40
|
+
def on_message(message)
|
41
|
+
puts " publisher got #{message.inspect}"
|
42
42
|
end
|
43
43
|
|
44
44
|
def on_close(code, reason)
|
@@ -94,6 +94,17 @@ module CelluloidPubsub
|
|
94
94
|
async.chat(subscription_data)
|
95
95
|
end
|
96
96
|
|
97
|
+
# checks if the message has the successfull subscription action
|
98
|
+
#
|
99
|
+
# @param [string] message
|
100
|
+
#
|
101
|
+
# @return [void]
|
102
|
+
#
|
103
|
+
# @api public
|
104
|
+
def succesfull_subscription?(message)
|
105
|
+
message.present? && message['client_action'].present? && message['client_action'] == 'successful_subscription'
|
106
|
+
end
|
107
|
+
|
97
108
|
# publishes to a channel some data (can be anything)
|
98
109
|
#
|
99
110
|
# @param [string] channel
|
@@ -77,6 +77,30 @@ describe CelluloidPubsub::Client::PubSubWorker do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
describe '#succesfull_subscription?' do
|
81
|
+
let(:message) { mock }
|
82
|
+
let(:action) { mock }
|
83
|
+
|
84
|
+
before(:each) do
|
85
|
+
message.stubs(:present?).returns(true)
|
86
|
+
message.stubs(:[]).with('client_action').returns('successful_subscription')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'checks the message and returns true' do
|
90
|
+
message.expects(:present?).returns(true)
|
91
|
+
message.stubs(:[]).with('client_action').returns('successful_subscription')
|
92
|
+
actual = @worker.succesfull_subscription?(message)
|
93
|
+
actual.should eq(true)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'checks the message and returns false' do
|
97
|
+
message.expects(:present?).returns(true)
|
98
|
+
message.stubs(:[]).with('client_action').returns('something_else')
|
99
|
+
actual = @worker.succesfull_subscription?(message)
|
100
|
+
actual.should eq(false)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
80
104
|
describe '#publish' do
|
81
105
|
let(:channel) { 'some_channel' }
|
82
106
|
let(:data) { 'some_message' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid_pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|