ably 1.2.1 → 1.2.3

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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/.rspec_parallel +3 -0
  3. data/.github/workflows/check.yml +24 -4
  4. data/.github/workflows/docs.yml +36 -0
  5. data/CHANGELOG.md +26 -0
  6. data/INTRO.md +14 -0
  7. data/ably.gemspec +1 -0
  8. data/lib/ably/auth.rb +26 -23
  9. data/lib/ably/models/auth_details.rb +9 -6
  10. data/lib/ably/models/channel_details.rb +69 -0
  11. data/lib/ably/models/channel_metrics.rb +107 -0
  12. data/lib/ably/models/channel_occupancy.rb +50 -0
  13. data/lib/ably/models/channel_options.rb +26 -3
  14. data/lib/ably/models/channel_state_change.rb +45 -15
  15. data/lib/ably/models/channel_status.rb +63 -0
  16. data/lib/ably/models/cipher_params.rb +36 -13
  17. data/lib/ably/models/connection_details.rb +91 -10
  18. data/lib/ably/models/connection_state_change.rb +54 -15
  19. data/lib/ably/models/delta_extras.rb +6 -7
  20. data/lib/ably/models/device_details.rb +60 -21
  21. data/lib/ably/models/device_push_details.rb +27 -19
  22. data/lib/ably/models/error_info.rb +59 -17
  23. data/lib/ably/models/http_paginated_response.rb +27 -5
  24. data/lib/ably/models/idiomatic_ruby_wrapper.rb +3 -2
  25. data/lib/ably/models/message.rb +64 -24
  26. data/lib/ably/models/message_encoders/base.rb +6 -0
  27. data/lib/ably/models/paginated_result.rb +29 -14
  28. data/lib/ably/models/presence_message.rb +72 -22
  29. data/lib/ably/models/protocol_message.rb +0 -4
  30. data/lib/ably/models/push_channel_subscription.rb +40 -15
  31. data/lib/ably/models/stats.rb +76 -40
  32. data/lib/ably/models/stats_types.rb +16 -40
  33. data/lib/ably/models/token_details.rb +34 -12
  34. data/lib/ably/models/token_request.rb +63 -2
  35. data/lib/ably/modules/async_wrapper.rb +1 -0
  36. data/lib/ably/modules/enum.rb +2 -0
  37. data/lib/ably/modules/event_emitter.rb +14 -1
  38. data/lib/ably/modules/model_common.rb +5 -0
  39. data/lib/ably/modules/state_emitter.rb +2 -0
  40. data/lib/ably/modules/state_machine.rb +4 -0
  41. data/lib/ably/realtime/channel/channel_properties.rb +9 -2
  42. data/lib/ably/realtime/channel/publisher.rb +2 -0
  43. data/lib/ably/realtime/channel/push_channel.rb +17 -10
  44. data/lib/ably/realtime/channel.rb +79 -42
  45. data/lib/ably/realtime/channels.rb +4 -3
  46. data/lib/ably/realtime/client/incoming_message_dispatcher.rb +6 -14
  47. data/lib/ably/realtime/client.rb +53 -32
  48. data/lib/ably/realtime/connection/connection_manager.rb +4 -0
  49. data/lib/ably/realtime/connection/websocket_transport.rb +4 -2
  50. data/lib/ably/realtime/connection.rb +94 -55
  51. data/lib/ably/realtime/presence.rb +61 -36
  52. data/lib/ably/realtime/push/admin.rb +16 -2
  53. data/lib/ably/realtime/push.rb +15 -3
  54. data/lib/ably/rest/channel/push_channel.rb +0 -3
  55. data/lib/ably/rest/channel.rb +33 -18
  56. data/lib/ably/rest/channels.rb +6 -3
  57. data/lib/ably/rest/client.rb +41 -35
  58. data/lib/ably/rest/presence.rb +27 -12
  59. data/lib/ably/rest/push/admin.rb +4 -0
  60. data/lib/ably/rest/push/device_registrations.rb +13 -2
  61. data/lib/ably/rest/push.rb +2 -0
  62. data/lib/ably/util/crypto.rb +14 -10
  63. data/lib/ably/version.rb +1 -1
  64. data/spec/acceptance/realtime/connection_spec.rb +0 -15
  65. data/spec/acceptance/realtime/message_spec.rb +3 -3
  66. data/spec/acceptance/rest/channel_spec.rb +18 -0
  67. data/spec/unit/models/channel_details_spec.rb +30 -0
  68. data/spec/unit/models/channel_metrics_spec.rb +42 -0
  69. data/spec/unit/models/channel_occupancy_spec.rb +17 -0
  70. data/spec/unit/models/channel_status_spec.rb +36 -0
  71. data/spec/unit/models/protocol_message_spec.rb +0 -26
  72. data/spec/unit/realtime/incoming_message_dispatcher_spec.rb +0 -38
  73. metadata +32 -3
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'shared/model_behaviour'
3
+
4
+ describe Ably::Models::ChannelDetails do
5
+ subject { Ably::Models::ChannelDetails(channel_id: 'channel-id-123-xyz', name: 'name', status: { isActive: 'true', occupancy: { metrics: { connections: 1, presence_connections: 2, presence_members: 2, presence_subscribers: 5, publishers: 7, subscribers: 9 } } }) }
6
+
7
+ describe '#channel_id' do
8
+ it 'should return channel id' do
9
+ expect(subject.channel_id).to eq('channel-id-123-xyz')
10
+ end
11
+ end
12
+
13
+ describe '#name' do
14
+ it 'should return name' do
15
+ expect(subject.name).to eq('name')
16
+ end
17
+ end
18
+
19
+ describe '#status' do
20
+ it 'should return status' do
21
+ expect(subject.status).to be_a(Ably::Models::ChannelStatus)
22
+ expect(subject.status.occupancy.metrics.connections).to eq(1)
23
+ expect(subject.status.occupancy.metrics.presence_connections).to eq(2)
24
+ expect(subject.status.occupancy.metrics.presence_members).to eq(2)
25
+ expect(subject.status.occupancy.metrics.presence_subscribers).to eq(5)
26
+ expect(subject.status.occupancy.metrics.publishers).to eq(7)
27
+ expect(subject.status.occupancy.metrics.subscribers).to eq(9)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'shared/model_behaviour'
3
+
4
+ describe Ably::Models::ChannelMetrics do
5
+ subject { Ably::Models::ChannelMetrics(connections: 1, presence_connections: 2, presence_members: 2, presence_subscribers: 5, publishers: 7, subscribers: 9) }
6
+
7
+ describe '#connections' do
8
+ it 'should return integer' do
9
+ expect(subject.connections).to eq(1)
10
+ end
11
+ end
12
+
13
+ describe '#presence_connections' do
14
+ it 'should return integer' do
15
+ expect(subject.presence_connections).to eq(2)
16
+ end
17
+ end
18
+
19
+ describe '#presence_members' do
20
+ it 'should return integer' do
21
+ expect(subject.presence_members).to eq(2)
22
+ end
23
+ end
24
+
25
+ describe '#presence_subscribers' do
26
+ it 'should return integer' do
27
+ expect(subject.presence_subscribers).to eq(5)
28
+ end
29
+ end
30
+
31
+ describe '#publishers' do
32
+ it 'should return integer' do
33
+ expect(subject.publishers).to eq(7)
34
+ end
35
+ end
36
+
37
+ describe '#subscribers' do
38
+ it 'should return integer' do
39
+ expect(subject.subscribers).to eq(9)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'shared/model_behaviour'
3
+
4
+ describe Ably::Models::ChannelOccupancy do
5
+ subject { Ably::Models::ChannelOccupancy({ metrics: { connections: 1, presence_connections: 2, presence_members: 2, presence_subscribers: 5, publishers: 7, subscribers: 9 } }) }
6
+
7
+ describe '#metrics' do
8
+ it 'should return attributes' do
9
+ expect(subject.metrics.connections).to eq(1)
10
+ expect(subject.metrics.presence_connections).to eq(2)
11
+ expect(subject.metrics.presence_members).to eq(2)
12
+ expect(subject.metrics.presence_subscribers).to eq(5)
13
+ expect(subject.metrics.publishers).to eq(7)
14
+ expect(subject.metrics.subscribers).to eq(9)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ require 'shared/model_behaviour'
3
+
4
+ describe Ably::Models::ChannelStatus do
5
+ subject { Ably::Models::ChannelStatus({ isActive: 'true', occupancy: { metrics: { connections: 1, presence_connections: 2, presence_members: 2, presence_subscribers: 5, publishers: 7, subscribers: 9 } } }) }
6
+
7
+ describe '#is_active' do
8
+ context 'when occupancy is active' do
9
+ subject { Ably::Models::ChannelStatus({ isActive: true, occupancy: { metrics: { connections: 1, presence_connections: 2, presence_members: 2, presence_subscribers: 5, publishers: 7, subscribers: 9 } } }) }
10
+
11
+ it 'should return true' do
12
+ expect(subject.is_active).to eq(true)
13
+ end
14
+ end
15
+
16
+ context 'when occupancy is not active' do
17
+ subject { Ably::Models::ChannelStatus({ isActive: false, occupancy: { metrics: { connections: 1, presence_connections: 2, presence_members: 2, presence_subscribers: 5, publishers: 7, subscribers: 9 } } }) }
18
+
19
+ it 'should return false' do
20
+ expect(subject.is_active).to eq(false)
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '#occupancy' do
26
+ it 'should return occupancy object' do
27
+ expect(subject.occupancy).to be_a(Ably::Models::ChannelOccupancy)
28
+ expect(subject.occupancy.metrics.connections).to eq(1)
29
+ expect(subject.occupancy.metrics.presence_connections).to eq(2)
30
+ expect(subject.occupancy.metrics.presence_members).to eq(2)
31
+ expect(subject.occupancy.metrics.presence_subscribers).to eq(5)
32
+ expect(subject.occupancy.metrics.publishers).to eq(7)
33
+ expect(subject.occupancy.metrics.subscribers).to eq(9)
34
+ end
35
+ end
36
+ end
@@ -400,32 +400,6 @@ describe Ably::Models::ProtocolMessage do
400
400
  end
401
401
  end
402
402
 
403
- context '#has_correct_message_size? (#TO3l8)' do
404
- context 'on presence' do
405
- it 'should return true when a message has correct size' do
406
- protocol_message = new_protocol_message(presence: [{ action: 1, data: 'x' * 100 }])
407
- expect(protocol_message.has_correct_message_size?).to eq(true)
408
- end
409
-
410
- it 'should return false when a message has not correct size' do
411
- protocol_message = new_protocol_message(presence: [{ action: 1, data: 'x' * 65537 }])
412
- expect(protocol_message.has_correct_message_size?).to eq(false)
413
- end
414
- end
415
-
416
- context 'on message' do
417
- it 'should return true when a message has correct size' do
418
- protocol_message = new_protocol_message(messages: [{ name: 'x' * 100 }])
419
- expect(protocol_message.has_correct_message_size?).to eq(true)
420
- end
421
-
422
- it 'should return false when a message has not correct size' do
423
- protocol_message = new_protocol_message(messages: [{ name: 'x' * 65537 }])
424
- expect(protocol_message.has_correct_message_size?).to eq(false)
425
- end
426
- end
427
- end
428
-
429
403
  context '#connection_details (#TR4o)' do
430
404
  let(:connection_details) { protocol_message.connection_details }
431
405
 
@@ -32,43 +32,5 @@ describe Ably::Realtime::Client::IncomingMessageDispatcher, :api_private do
32
32
  expect(subject).to receive_message_chain(:logger, :warn)
33
33
  msgbus.publish :protocol_message, Ably::Models::ProtocolMessage.new(:action => :attached, channel: 'unknown')
34
34
  end
35
-
36
- context 'TO3l8' do
37
- context 'on action presence' do
38
- let(:presence) { 101.times.map { { data: 'x' * 655 } } }
39
-
40
- let(:protocol_message) do
41
- Ably::Models::ProtocolMessage.new(action: :presence, channel: 'default', presence: presence, connection_serial: 123123123)
42
- end
43
-
44
- it 'should raise a protocol error when message size exceeded 65536 bytes' do
45
- allow(connection).to receive(:serial).and_return(12312312)
46
- allow(subject).to receive(:update_connection_recovery_info)
47
- allow(subject).to receive_message_chain(:logger, :debug)
48
- allow(subject).to receive_message_chain(:logger, :warn)
49
- expect(subject).to receive_message_chain(:logger, :fatal)
50
-
51
- msgbus.publish :protocol_message, protocol_message
52
- end
53
- end
54
-
55
- context 'on action message' do
56
- let(:messages) { 101.times.map { { data: 'x' * 655 } } }
57
-
58
- let(:protocol_message) do
59
- Ably::Models::ProtocolMessage.new(action: :message, channel: 'default', messages: messages, connection_serial: 123123123)
60
- end
61
-
62
- it 'should raise a protocol error when message size exceeded 65536 bytes' do
63
- allow(connection).to receive(:serial).and_return(12312312)
64
- allow(subject).to receive(:update_connection_recovery_info)
65
- allow(subject).to receive_message_chain(:logger, :debug)
66
- allow(subject).to receive_message_chain(:logger, :warn)
67
- expect(subject).to receive_message_chain(:logger, :fatal)
68
-
69
- msgbus.publish :protocol_message, protocol_message
70
- end
71
- end
72
- end
73
35
  end
74
36
  end
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: 1.2.1
4
+ version: 1.2.3
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: 2022-05-19 00:00:00.000000000 Z
12
+ date: 2022-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -193,6 +193,20 @@ dependencies:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
195
  version: 3.11.0
196
+ - !ruby/object:Gem::Dependency
197
+ name: rspec_junit_formatter
198
+ requirement: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - "~>"
201
+ - !ruby/object:Gem::Version
202
+ version: 0.5.1
203
+ type: :development
204
+ prerelease: false
205
+ version_requirements: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: 0.5.1
196
210
  - !ruby/object:Gem::Dependency
197
211
  name: rspec-retry
198
212
  requirement: !ruby/object:Gem::Requirement
@@ -356,13 +370,16 @@ extensions: []
356
370
  extra_rdoc_files: []
357
371
  files:
358
372
  - ".editorconfig"
373
+ - ".github/workflows/.rspec_parallel"
359
374
  - ".github/workflows/check.yml"
375
+ - ".github/workflows/docs.yml"
360
376
  - ".gitignore"
361
377
  - ".gitmodules"
362
378
  - ".rspec"
363
379
  - CHANGELOG.md
364
380
  - COPYRIGHT
365
381
  - Gemfile
382
+ - INTRO.md
366
383
  - LICENSE
367
384
  - MAINTAINERS.md
368
385
  - README.md
@@ -376,8 +393,12 @@ files:
376
393
  - lib/ably/exceptions.rb
377
394
  - lib/ably/logger.rb
378
395
  - lib/ably/models/auth_details.rb
396
+ - lib/ably/models/channel_details.rb
397
+ - lib/ably/models/channel_metrics.rb
398
+ - lib/ably/models/channel_occupancy.rb
379
399
  - lib/ably/models/channel_options.rb
380
400
  - lib/ably/models/channel_state_change.rb
401
+ - lib/ably/models/channel_status.rb
381
402
  - lib/ably/models/cipher_params.rb
382
403
  - lib/ably/models/connection_details.rb
383
404
  - lib/ably/models/connection_state_change.rb
@@ -516,7 +537,11 @@ files:
516
537
  - spec/unit/auth_spec.rb
517
538
  - spec/unit/logger_spec.rb
518
539
  - spec/unit/models/auth_details_spec.rb
540
+ - spec/unit/models/channel_details_spec.rb
541
+ - spec/unit/models/channel_metrics_spec.rb
542
+ - spec/unit/models/channel_occupancy_spec.rb
519
543
  - spec/unit/models/channel_state_change_spec.rb
544
+ - spec/unit/models/channel_status_spec.rb
520
545
  - spec/unit/models/cipher_params_spec.rb
521
546
  - spec/unit/models/connection_details_spec.rb
522
547
  - spec/unit/models/connection_state_change_spec.rb
@@ -579,7 +604,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
579
604
  - !ruby/object:Gem::Version
580
605
  version: '0'
581
606
  requirements: []
582
- rubygems_version: 3.3.14
607
+ rubygems_version: 3.2.32
583
608
  signing_key:
584
609
  specification_version: 4
585
610
  summary: A Ruby client library for ably.io realtime messaging implemented using EventMachine
@@ -633,7 +658,11 @@ test_files:
633
658
  - spec/unit/auth_spec.rb
634
659
  - spec/unit/logger_spec.rb
635
660
  - spec/unit/models/auth_details_spec.rb
661
+ - spec/unit/models/channel_details_spec.rb
662
+ - spec/unit/models/channel_metrics_spec.rb
663
+ - spec/unit/models/channel_occupancy_spec.rb
636
664
  - spec/unit/models/channel_state_change_spec.rb
665
+ - spec/unit/models/channel_status_spec.rb
637
666
  - spec/unit/models/cipher_params_spec.rb
638
667
  - spec/unit/models/connection_details_spec.rb
639
668
  - spec/unit/models/connection_state_change_spec.rb