ably 0.8.10 → 0.8.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: ebdb3de0d61032d4177a8fe51975ac1967e7fe9e
4
- data.tar.gz: 5cdaef2668a7e4fd9eac0027115bac896c8438f7
3
+ metadata.gz: c2940c3999a909ad6243c5c9f7b58577bb754a65
4
+ data.tar.gz: a26e8dcb896d65db2ac1037fda94229a6cafa0b7
5
5
  SHA512:
6
- metadata.gz: 4aa4df9755c680ddb24e927bfd82fcce0cb8909bad91b8d91e367a1d14b14ff3accc83dd4c668e4dec0a734be9ef82e56c8eb31f2d20f6b71bec8432ca1082ab
7
- data.tar.gz: 8dc667ac95090f550e9606fac468f89f4029979955967da6aba5b31ded8ac7a3d3be24c40b6f2074a519ff8aae52e038bb5d983c5cc11b2122ccadd43267482f
6
+ metadata.gz: 17a1afa89167265c13c1f63ed0a534f8af6cfbe799684cdac328331e24fe33851341cc5ac2ff214feb8fa5092ec6d461eb8c8d37e56032b870e294bca32c3d4b
7
+ data.tar.gz: c69805bf390839041e2d82283e0aedc1d22baa181386deeb870f267093f235d97419399c246fa7ed04dedd22c4430b6ec8f22f5325d2890559c12619fbb48c66
@@ -4,6 +4,9 @@ module Ably::Modules
4
4
  # Message emitter, subscriber and unsubscriber (Pub/Sub) functionality common to Channels and Presence
5
5
  # In addition to standard Pub/Sub functionality, it allows subscribers to subscribe to :all.
6
6
  module MessageEmitter
7
+
8
+ include Ably::Modules::SafeYield
9
+
7
10
  # Subscribe to events on this object
8
11
  #
9
12
  # @param names [String,Symbol] Optional, the event name(s) to subscribe to. Defaults to `:all` events
@@ -50,8 +53,8 @@ module Ably::Modules
50
53
  #
51
54
  # @api private
52
55
  def emit_message(name, payload)
53
- message_emitter_subscriptions[:all].each { |cb| cb.call(payload) }
54
- message_emitter_subscriptions[name].each { |cb| cb.call(payload) } if name
56
+ message_emitter_subscriptions[:all].each { |cb| safe_yield(cb, payload) }
57
+ message_emitter_subscriptions[name].each { |cb| safe_yield(cb, payload) } if name
55
58
  end
56
59
 
57
60
  private
@@ -1,3 +1,3 @@
1
1
  module Ably
2
- VERSION = '0.8.10'
2
+ VERSION = '0.8.11'
3
3
  end
@@ -908,6 +908,25 @@ describe Ably::Realtime::Channel, :event_machine do
908
908
  end
909
909
  end
910
910
 
911
+ context 'with a callback that raises an exception' do
912
+ let(:exception) { StandardError.new("Intentional error") }
913
+
914
+ it 'logs the error and continues' do
915
+ emitted_exception = false
916
+ expect(client.logger).to receive(:error).with(/#{exception.message}/)
917
+ channel.subscribe('click') do |message|
918
+ emitted_exception = true
919
+ raise exception
920
+ end
921
+ channel.publish('click', 'data') do
922
+ EventMachine.add_timer(1) do
923
+ expect(emitted_exception).to eql(true)
924
+ stop_reactor
925
+ end
926
+ end
927
+ end
928
+ end
929
+
911
930
  context 'many times with different event names' do
912
931
  it 'filters events accordingly to each callback' do
913
932
  click_callback = proc { |message| messages << message }
@@ -1463,6 +1463,25 @@ describe Ably::Realtime::Presence, :event_machine do
1463
1463
  stop_reactor
1464
1464
  end
1465
1465
  end
1466
+
1467
+ context 'with a callback that raises an exception' do
1468
+ let(:exception) { StandardError.new("Intentional error") }
1469
+
1470
+ it 'logs the error and continues' do
1471
+ emitted_exception = false
1472
+ expect(client_one.logger).to receive(:error).with(/#{exception.message}/)
1473
+ presence_client_one.subscribe do |presence_message|
1474
+ emitted_exception = true
1475
+ raise exception
1476
+ end
1477
+ presence_client_one.enter do
1478
+ EventMachine.add_timer(1) do
1479
+ expect(emitted_exception).to eql(true)
1480
+ stop_reactor
1481
+ end
1482
+ end
1483
+ end
1484
+ end
1466
1485
  end
1467
1486
 
1468
1487
  context '#unsubscribe' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ably
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.10
4
+ version: 0.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lewis Marshall
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-01 00:00:00.000000000 Z
12
+ date: 2016-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine