ably 1.2.1 → 1.2.2

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
  SHA256:
3
- metadata.gz: 6d535fd596cbed132fc9c540fb46997c5fcaafeae4b4531ab6fbe02dba33178f
4
- data.tar.gz: 1792b4e4f47d7044d0a937d3b75f9e3b9d9f1d6a436a36bfde2f9e65ae3f2552
3
+ metadata.gz: 254c6088b3e3ef0d8cd6d2837b4efc73c2c7c04d8b7d4c61d416f023a8933603
4
+ data.tar.gz: 91d7b17e533b41ede327696aff66dd97ea35d6f7cf2a9fee9fd467fa42e9041e
5
5
  SHA512:
6
- metadata.gz: fad634a453ebbb3d1b05ad13fa7c3683e794635862267376920aa7d43e93afeab7c5ba06398609e048d7f421f8d10f80f9866828f07468e153be843f6b38a136
7
- data.tar.gz: 1d76ae8ffe50a043b82fbb553af787a2a49665909d802f6471644e9614d81677d04c38926cb34890a2daeef2d498cabe7c39817c40fbb8d1be88070d2d103669
6
+ metadata.gz: 8d51a067f02691481cf9489f82334f9200ef9ae00d71c2639c26a8d0b8fa62fbd76921fafb114699d4bf0d8e0f0e46f865bb07411a4dc4d6197a7ffeb9ebd6be
7
+ data.tar.gz: a392f7f5ec08ab445aaad519e45dc841090950402516ef2bafe3863817af77536b85549701acfc52e4a171544b79a190b499b3f8d32552a9a08973bf60831c3d
@@ -12,6 +12,7 @@ jobs:
12
12
  matrix:
13
13
  ruby: [ '2.7', '3.0', '3.1' ]
14
14
  protocol: [ 'json', 'msgpack' ]
15
+ type: [ 'unit', 'acceptance' ]
15
16
  steps:
16
17
  - uses: actions/checkout@v2
17
18
  with:
@@ -20,15 +21,23 @@ jobs:
20
21
  with:
21
22
  ruby-version: ${{ matrix.ruby }}
22
23
  bundler-cache: true
23
- - env:
24
- RSPEC_RETRY: true
24
+ - name: 'Run ${{ matrix.type }} tests on ruby ${{ matrix.ruby }} (${{ matrix.protocol }} protocol)'
25
+ env:
25
26
  PARALLEL_TEST_PROCESSORS: 2
27
+ RSPEC_RETRY: true
26
28
  PROTOCOL: ${{ matrix.protocol }}
27
- run: ./spec/run_parallel_tests
29
+ run: bundle exec parallel_rspec --prefix-output-with-test-env-number -- --format documentation --format RspecJunitFormatter --out ${{ matrix.protocol }}-${{ matrix.type }}-ruby-${{ matrix.ruby }}.junit -- spec/${{ matrix.type }}
30
+ - name: Upload test results
31
+ if: always()
32
+ uses: ably-labs/test-observability-action@main
33
+ with:
34
+ server-url: 'https://test-observability.herokuapp.com'
35
+ server-auth: ${{ secrets.TEST_OBSERVABILITY_SERVER_AUTH_KEY }}
36
+ path: '.'
28
37
  - uses: coverallsapp/github-action@1.1.3
29
38
  with:
30
39
  github-token: ${{ secrets.GITHUB_TOKEN }}
31
- flag-name: run-ruby_${{ matrix.ruby }}-${{ matrix.protocol }}_protocol
40
+ flag-name: ruby-${{ matrix.ruby }}-${{ matrix.protocol }}-${{ matrix.type }}
32
41
  parallel: true
33
42
  finish:
34
43
  needs: check
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.2.2](https://github.com/ably/ably-ruby/tree/v1.2.2)
4
+
5
+ [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.2.1...v1.2.2)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Add support to get channel lifecycle status [\#362](https://github.com/ably/ably-ruby/issues/362)
10
+
3
11
  ## [v1.2.1](https://github.com/ably/ably-ruby/tree/v1.2.1)
4
12
 
5
13
  [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.2.0...v1.2.1)
data/ably.gemspec CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'rake', '~> 13.0'
33
33
  spec.add_development_dependency 'redcarpet', '~> 3.3'
34
34
  spec.add_development_dependency 'rspec', '~> 3.11.0'
35
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5.1'
35
36
  spec.add_development_dependency 'rspec-retry', '~> 0.6'
36
37
  spec.add_development_dependency 'yard', '~> 0.9'
37
38
  spec.add_development_dependency 'rspec-instafail', '~> 1.0'
@@ -0,0 +1,59 @@
1
+ module Ably::Models
2
+ # Convert token details argument to a {ChannelDetails} object
3
+ #
4
+ # @param attributes (see #initialize)
5
+ #
6
+ # @return [ChannelDetails]
7
+ def self.ChannelDetails(attributes)
8
+ case attributes
9
+ when ChannelDetails
10
+ return attributes
11
+ else
12
+ ChannelDetails.new(attributes)
13
+ end
14
+ end
15
+
16
+ # ChannelDetails is a type that represents information for a channel including channelId, name, status and occupancy (CHD1)
17
+ #
18
+ class ChannelDetails
19
+ extend Ably::Modules::Enum
20
+ extend Forwardable
21
+ include Ably::Modules::ModelCommon
22
+
23
+ # The attributes of ChannelDetails (CHD2)
24
+ #
25
+ attr_reader :attributes
26
+
27
+ alias_method :to_h, :attributes
28
+
29
+ # Initialize a new ChannelDetails
30
+ #
31
+ def initialize(attrs)
32
+ @attributes = IdiomaticRubyWrapper(attrs.clone)
33
+ end
34
+
35
+ # The identifier of the channel (CHD2a)
36
+ #
37
+ # @return [String]
38
+ #
39
+ def channel_id
40
+ attributes[:channel_id]
41
+ end
42
+
43
+ # The identifier of the channel (CHD2a)
44
+ #
45
+ # @return [String]
46
+ #
47
+ def name
48
+ attributes[:name]
49
+ end
50
+
51
+ # The status of the channel (CHD2b)
52
+ #
53
+ # @return [Ably::Models::ChannelStatus, nil]
54
+ #
55
+ def status
56
+ Ably::Models::ChannelStatus(attributes[:status])
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,84 @@
1
+ module Ably::Models
2
+ # Convert token details argument to a {ChannelMetrics} object
3
+ #
4
+ # @param attributes (see #initialize)
5
+ #
6
+ # @return [ChannelMetrics]
7
+ def self.ChannelMetrics(attributes)
8
+ case attributes
9
+ when ChannelMetrics
10
+ return attributes
11
+ else
12
+ ChannelMetrics.new(attributes)
13
+ end
14
+ end
15
+
16
+ # ChannelMetrics is a type that contains the count of publishers and subscribers, connections and presenceConnections,
17
+ # presenceMembers and presenceSubscribers (CHM1)
18
+ #
19
+ class ChannelMetrics
20
+ extend Ably::Modules::Enum
21
+ extend Forwardable
22
+ include Ably::Modules::ModelCommon
23
+
24
+ # The attributes of ChannelMetrics (CHM2)
25
+ #
26
+ attr_reader :attributes
27
+
28
+ alias_method :to_h, :attributes
29
+
30
+ # Initialize a new ChannelMetrics
31
+ #
32
+ def initialize(attrs)
33
+ @attributes = IdiomaticRubyWrapper(attrs.clone)
34
+ end
35
+
36
+ # The total number of connections to the channel (CHM2a)
37
+ #
38
+ # @return [Integer]
39
+ #
40
+ def connections
41
+ attributes[:connections]
42
+ end
43
+
44
+ # The total number of presence connections to the channel (CHM2b)
45
+ #
46
+ # @return [Integer]
47
+ #
48
+ def presence_connections
49
+ attributes[:presence_connections]
50
+ end
51
+
52
+ # The total number of presence members for the channel (CHM2c)
53
+ #
54
+ # @return [Integer]
55
+ #
56
+ def presence_members
57
+ attributes[:presence_members]
58
+ end
59
+
60
+ # The total number of presence subscribers for the channel (CHM2d)
61
+ #
62
+ # @return [Integer]
63
+ #
64
+ def presence_subscribers
65
+ attributes[:presence_subscribers]
66
+ end
67
+
68
+ # The total number of publishers to the channel (CHM2e)
69
+ #
70
+ # @return [Integer]
71
+ #
72
+ def publishers
73
+ attributes[:publishers]
74
+ end
75
+
76
+ # The total number of subscribers to the channel (CHM2f)
77
+ #
78
+ # @return [Integer]
79
+ #
80
+ def subscribers
81
+ attributes[:subscribers]
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,43 @@
1
+ module Ably::Models
2
+ # Convert token details argument to a {ChannelOccupancy} object
3
+ #
4
+ # @param attributes (see #initialize)
5
+ #
6
+ # @return [ChannelOccupancy]
7
+ def self.ChannelOccupancy(attributes)
8
+ case attributes
9
+ when ChannelOccupancy
10
+ return attributes
11
+ else
12
+ ChannelOccupancy.new(attributes)
13
+ end
14
+ end
15
+
16
+ # Type that contain channel metrics (CHO1)
17
+ #
18
+ class ChannelOccupancy
19
+ extend Ably::Modules::Enum
20
+ extend Forwardable
21
+ include Ably::Modules::ModelCommon
22
+
23
+ # The attributes of ChannelOccupancy (CH02)
24
+ #
25
+ attr_reader :attributes
26
+
27
+ alias_method :to_h, :attributes
28
+
29
+ # Initialize a new ChannelOccupancy
30
+ #
31
+ def initialize(attrs)
32
+ @attributes = IdiomaticRubyWrapper(attrs.clone)
33
+ end
34
+
35
+ # Metrics object (CHO2a)
36
+ #
37
+ # @return [Ably::Models::ChannelMetrics, nil]
38
+ #
39
+ def metrics
40
+ Ably::Models::ChannelMetrics(attributes[:metrics])
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,53 @@
1
+ module Ably::Models
2
+ # Convert token details argument to a {ChannelStatus} object
3
+ #
4
+ # @param attributes (see #initialize)
5
+ #
6
+ # @return [ChannelStatus]
7
+ def self.ChannelStatus(attributes)
8
+ case attributes
9
+ when ChannelStatus
10
+ return attributes
11
+ else
12
+ ChannelStatus.new(attributes)
13
+ end
14
+ end
15
+
16
+ # ChannelStatus is a type that contains status and occupancy for a channel (CHS1)
17
+ #
18
+ class ChannelStatus
19
+ extend Ably::Modules::Enum
20
+ extend Forwardable
21
+ include Ably::Modules::ModelCommon
22
+
23
+ # The attributes of ChannelStatus (CHS2)
24
+ #
25
+ attr_reader :attributes
26
+
27
+ alias_method :to_h, :attributes
28
+
29
+ # Initialize a new ChannelStatus
30
+ #
31
+ def initialize(attrs)
32
+ @attributes = IdiomaticRubyWrapper(attrs.clone)
33
+ end
34
+
35
+ # Represents if the channel is active (CHS2a)
36
+ #
37
+ # @return [Boolean]
38
+ #
39
+ def is_active
40
+ attributes[:isActive]
41
+ end
42
+ alias_method :active?, :is_active
43
+ alias_method :is_active?, :is_active
44
+
45
+ # Occupancy ChannelOccupancy – occupancy is an object containing the metrics for the channel (CHS2b)
46
+ #
47
+ # @return [Ably::Models::ChannelOccupancy, nil]
48
+ #
49
+ def occupancy
50
+ Ably::Models::ChannelOccupancy(attributes[:occupancy])
51
+ end
52
+ end
53
+ end
@@ -161,6 +161,13 @@ module Ably
161
161
  end
162
162
  alias options= set_options
163
163
 
164
+ # Makes GET request for channel details (#RSL8, #RSL8a)
165
+ #
166
+ # @return [Ably::Models::ChannelDetails]
167
+ def status
168
+ Ably::Models::ChannelDetails.new(client.get(base_path).body)
169
+ end
170
+
164
171
  private
165
172
 
166
173
  def base_path
data/lib/ably/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Ably
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  PROTOCOL_VERSION = '1.2'
4
4
 
5
5
  # @api private
@@ -595,5 +595,23 @@ describe Ably::Rest::Channel do
595
595
  expect(channel.presence).to be_a(Ably::Rest::Presence)
596
596
  end
597
597
  end
598
+
599
+ context '#status' do
600
+ let(:channel_name) { "persisted:#{random_str(4)}" }
601
+ let(:channel) { client.channel(channel_name) }
602
+ let(:channel_details) { channel.status }
603
+
604
+ it 'should return channel details status (#RSL8, #RSL8a)' do
605
+ expect(channel_details.channel_id).to eq(channel_name)
606
+ expect(channel_details.name).to eq(channel_name)
607
+ expect(channel_details.status).to be_a(Ably::Models::ChannelStatus)
608
+ expect(channel_details.status.is_active).to eq(true)
609
+ expect(channel_details.status.occupancy.metrics.publishers).to eq(0)
610
+ expect(channel_details.status.occupancy.metrics.subscribers).to eq(0)
611
+ expect(channel_details.status.occupancy.metrics.presence_connections).to eq(0)
612
+ expect(channel_details.status.occupancy.metrics.presence_members).to eq(0)
613
+ expect(channel_details.status.occupancy.metrics.presence_subscribers).to eq(0)
614
+ end
615
+ end
598
616
  end
599
617
  end
@@ -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
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.2
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-06-08 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
@@ -376,8 +390,12 @@ files:
376
390
  - lib/ably/exceptions.rb
377
391
  - lib/ably/logger.rb
378
392
  - lib/ably/models/auth_details.rb
393
+ - lib/ably/models/channel_details.rb
394
+ - lib/ably/models/channel_metrics.rb
395
+ - lib/ably/models/channel_occupancy.rb
379
396
  - lib/ably/models/channel_options.rb
380
397
  - lib/ably/models/channel_state_change.rb
398
+ - lib/ably/models/channel_status.rb
381
399
  - lib/ably/models/cipher_params.rb
382
400
  - lib/ably/models/connection_details.rb
383
401
  - lib/ably/models/connection_state_change.rb
@@ -516,7 +534,11 @@ files:
516
534
  - spec/unit/auth_spec.rb
517
535
  - spec/unit/logger_spec.rb
518
536
  - spec/unit/models/auth_details_spec.rb
537
+ - spec/unit/models/channel_details_spec.rb
538
+ - spec/unit/models/channel_metrics_spec.rb
539
+ - spec/unit/models/channel_occupancy_spec.rb
519
540
  - spec/unit/models/channel_state_change_spec.rb
541
+ - spec/unit/models/channel_status_spec.rb
520
542
  - spec/unit/models/cipher_params_spec.rb
521
543
  - spec/unit/models/connection_details_spec.rb
522
544
  - spec/unit/models/connection_state_change_spec.rb
@@ -633,7 +655,11 @@ test_files:
633
655
  - spec/unit/auth_spec.rb
634
656
  - spec/unit/logger_spec.rb
635
657
  - spec/unit/models/auth_details_spec.rb
658
+ - spec/unit/models/channel_details_spec.rb
659
+ - spec/unit/models/channel_metrics_spec.rb
660
+ - spec/unit/models/channel_occupancy_spec.rb
636
661
  - spec/unit/models/channel_state_change_spec.rb
662
+ - spec/unit/models/channel_status_spec.rb
637
663
  - spec/unit/models/cipher_params_spec.rb
638
664
  - spec/unit/models/connection_details_spec.rb
639
665
  - spec/unit/models/connection_state_change_spec.rb