celluloid_pubsub 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f44862fbd5f5bbedf3b8d9c2b108cec95fa6076
4
- data.tar.gz: bb98ceee51189f93220dfa68b3b4b473c0982d23
3
+ metadata.gz: f553146c4281cefdba37767bc0c34aa7cac8fcb5
4
+ data.tar.gz: e847a478522bdca68ae7e700f816224a49564814
5
5
  SHA512:
6
- metadata.gz: 90a4cfbc1b5db576860cf66e44023a9f31dcd1f3834ee6dcdec73bd0ae6c852443ac544d5c1f2186f173d5b5e62767066ff0a46fb8fc7ac278c0b5f1d82f4d3f
7
- data.tar.gz: 7c4ada019199d0bf1b64179d1232ee03ae0dbe403955e3cf657b8b2c7bf122cea5125fbaef8993f8f56b9a6f52ff8c43f065a66ac0bc8abdef025f5a5145f84e
6
+ metadata.gz: e4a6abb2fa27acb9086e2f482b2fb78fdb197b14ffdc9037796e8b7b917e41963957b50565887072d8931a6dca0da5e791546e5c679ce2829433b48d1842db97
7
+ data.tar.gz: fc1c12cb83b08d4a82052f79624fd72c9492e0d446a5693bdb54a3de5fd246657c843757554d76a9869285f75ee77c6268ba8427747b307c1d9577c573656fe2
@@ -7,7 +7,7 @@ class Subscriber
7
7
  include Celluloid::Logger
8
8
 
9
9
  def initialize
10
- @client = CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
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 = CelluloidPubsub::Client.connect(actor: Actor.current) do |ws|
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
- def on_message(message)
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
@@ -17,7 +17,7 @@ module CelluloidPubsub
17
17
  # minor release version
18
18
  MINOR = 0
19
19
  # tiny release version
20
- TINY = 10
20
+ TINY = 11
21
21
  # prelease version ( set this only if it is a prelease)
22
22
  PRE = nil
23
23
 
@@ -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.10
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-03-24 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid