ably 1.1.7 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/check.yml +1 -1
  3. data/CHANGELOG.md +99 -0
  4. data/COPYRIGHT +1 -1
  5. data/README.md +2 -2
  6. data/SPEC.md +0 -7
  7. data/UPDATING.md +30 -0
  8. data/ably.gemspec +11 -24
  9. data/lib/ably/auth.rb +8 -8
  10. data/lib/ably/logger.rb +4 -4
  11. data/lib/ably/models/channel_options.rb +97 -0
  12. data/lib/ably/models/connection_details.rb +8 -2
  13. data/lib/ably/models/delta_extras.rb +29 -0
  14. data/lib/ably/models/device_details.rb +1 -1
  15. data/lib/ably/models/error_info.rb +6 -2
  16. data/lib/ably/models/idiomatic_ruby_wrapper.rb +4 -0
  17. data/lib/ably/models/message.rb +14 -3
  18. data/lib/ably/models/protocol_message.rb +23 -14
  19. data/lib/ably/models/token_details.rb +7 -2
  20. data/lib/ably/models/token_request.rb +1 -1
  21. data/lib/ably/modules/ably.rb +1 -1
  22. data/lib/ably/modules/channels_collection.rb +22 -2
  23. data/lib/ably/modules/conversions.rb +34 -0
  24. data/lib/ably/realtime/auth.rb +2 -2
  25. data/lib/ably/realtime/channel/channel_manager.rb +16 -4
  26. data/lib/ably/realtime/channel/channel_state_machine.rb +10 -1
  27. data/lib/ably/realtime/channel/publisher.rb +3 -2
  28. data/lib/ably/realtime/channel.rb +54 -22
  29. data/lib/ably/realtime/channels.rb +1 -1
  30. data/lib/ably/realtime/connection/connection_manager.rb +13 -4
  31. data/lib/ably/realtime/connection/connection_state_machine.rb +4 -0
  32. data/lib/ably/realtime/connection.rb +0 -3
  33. data/lib/ably/rest/channel.rb +28 -35
  34. data/lib/ably/rest/client.rb +23 -8
  35. data/lib/ably/rest/middleware/encoder.rb +1 -1
  36. data/lib/ably/rest/middleware/exceptions.rb +1 -1
  37. data/lib/ably/rest/middleware/external_exceptions.rb +1 -1
  38. data/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb +1 -1
  39. data/lib/ably/rest/middleware/logger.rb +1 -1
  40. data/lib/ably/rest/middleware/parse_json.rb +1 -1
  41. data/lib/ably/rest/middleware/parse_message_pack.rb +1 -1
  42. data/lib/ably/util/crypto.rb +1 -1
  43. data/lib/ably/version.rb +2 -2
  44. data/spec/acceptance/realtime/channel_spec.rb +458 -27
  45. data/spec/acceptance/realtime/channels_spec.rb +59 -7
  46. data/spec/acceptance/realtime/connection_failures_spec.rb +56 -1
  47. data/spec/acceptance/realtime/connection_spec.rb +270 -1
  48. data/spec/acceptance/realtime/message_spec.rb +77 -0
  49. data/spec/acceptance/realtime/presence_spec.rb +18 -1
  50. data/spec/acceptance/rest/auth_spec.rb +18 -0
  51. data/spec/acceptance/rest/channel_spec.rb +73 -11
  52. data/spec/acceptance/rest/channels_spec.rb +23 -6
  53. data/spec/acceptance/rest/client_spec.rb +3 -3
  54. data/spec/acceptance/rest/message_spec.rb +61 -3
  55. data/spec/lib/unit/models/channel_options_spec.rb +52 -0
  56. data/spec/run_parallel_tests +2 -7
  57. data/spec/support/test_app.rb +1 -1
  58. data/spec/unit/logger_spec.rb +6 -14
  59. data/spec/unit/models/delta_extras_spec.rb +14 -0
  60. data/spec/unit/models/error_info_spec.rb +17 -1
  61. data/spec/unit/models/message_spec.rb +38 -0
  62. data/spec/unit/models/protocol_message_spec.rb +77 -27
  63. data/spec/unit/models/token_details_spec.rb +14 -0
  64. data/spec/unit/realtime/channel_spec.rb +2 -1
  65. data/spec/unit/realtime/channels_spec.rb +53 -15
  66. data/spec/unit/rest/channel_spec.rb +40 -7
  67. data/spec/unit/rest/channels_spec.rb +81 -14
  68. data/spec/unit/rest/client_spec.rb +27 -0
  69. metadata +46 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99da4e4f2a2934965e19a4541968e651405886d6a0814786e701fc182d6e10ef
4
- data.tar.gz: f026b079b0b8969df7efe18e99413bc7d79035c2a055c46d2166d12da1d8a8ef
3
+ metadata.gz: 6d535fd596cbed132fc9c540fb46997c5fcaafeae4b4531ab6fbe02dba33178f
4
+ data.tar.gz: 1792b4e4f47d7044d0a937d3b75f9e3b9d9f1d6a436a36bfde2f9e65ae3f2552
5
5
  SHA512:
6
- metadata.gz: 98ac241fc8720f4da77cabe14b8cd2c6b705c8ccac33cd2f81f9c937cb75ddba173e1f129670c0392f9f2a63e0809dba995d71700832d16efbc6aa24f5ae6ad3
7
- data.tar.gz: 74b4bc0c6aef5ed2ffccf41a432d8d4588a694ef0cad301e8163f8a4607536a382306d22fe0a349c95dbaad7080690220f788de8bb96033588b275e099663eaa
6
+ metadata.gz: fad634a453ebbb3d1b05ad13fa7c3683e794635862267376920aa7d43e93afeab7c5ba06398609e048d7f421f8d10f80f9866828f07468e153be843f6b38a136
7
+ data.tar.gz: 1d76ae8ffe50a043b82fbb553af787a2a49665909d802f6471644e9614d81677d04c38926cb34890a2daeef2d498cabe7c39817c40fbb8d1be88070d2d103669
@@ -10,7 +10,7 @@ jobs:
10
10
  continue-on-error: true
11
11
  strategy:
12
12
  matrix:
13
- ruby: [ '2.5', '2.6', '2.7', '3.0' ]
13
+ ruby: [ '2.7', '3.0', '3.1' ]
14
14
  protocol: [ 'json', 'msgpack' ]
15
15
  steps:
16
16
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,104 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.2.1](https://github.com/ably/ably-ruby/tree/v1.2.1)
4
+
5
+ [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.2.0...v1.2.1)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Update Ruby version \(and Gemfile.lock dependencies\) [\#253](https://github.com/ably/ably-ruby/issues/253)
10
+ - Error not emitted when failing to connect to an endpoint indefinitely [\#233](https://github.com/ably/ably-ruby/issues/233)
11
+ - Connection errors when there should be warnings [\#198](https://github.com/ably/ably-ruby/issues/198)
12
+ - Implement presence re-entry requirement change for 1.1 [\#185](https://github.com/ably/ably-ruby/issues/185)
13
+
14
+ **Closed issues:**
15
+
16
+ - Update urls in readme [\#353](https://github.com/ably/ably-ruby/issues/353)
17
+ - Reconsider required Ruby version [\#344](https://github.com/ably/ably-ruby/issues/344)
18
+
19
+ ## [v1.2.0](https://github.com/ably/ably-ruby/tree/v1.2.0)
20
+
21
+ [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.1.8...v1.2.0)
22
+
23
+ This release updates ably-ruby to be compliant with the 1.2 version of the Ably client library feature specification. There are some minor breaking changes, please see [the migration guide](./UPDATING.md) for more information.
24
+
25
+ **Closed issues:**
26
+
27
+ - Add Channel.setOptions method [\#291](https://github.com/ably/ably-ruby/issues/291)
28
+ - Add support for channel params [\#288](https://github.com/ably/ably-ruby/issues/288)
29
+ - Use ATTACH_RESUME flag for unclean attaches [\#287](https://github.com/ably/ably-ruby/issues/287)
30
+ - Add ChannelOptions param to Channels.get [\#285](https://github.com/ably/ably-ruby/issues/285)
31
+ - Update library to adhere to new spec for token renewal (see [the spec definition](https://docs.ably.io/client-lib-development-guide/features/#RSA4b) for more info) [\#268](https://github.com/ably/ably-ruby/issues/268)
32
+
33
+ **Merged pull requests:**
34
+
35
+ - Add migration guide from 1.1.8 to 1.2.0 [\#348](https://github.com/ably/ably-ruby/pull/348) ([TheSmartnik](https://github.com/TheSmartnik))
36
+ - RTL21 [\#345](https://github.com/ably/ably-ruby/pull/345) ([lukaszsliwa](https://github.com/lukaszsliwa))
37
+ - RTL4j [\#341](https://github.com/ably/ably-ruby/pull/341) ([TheSmartnik](https://github.com/TheSmartnik))
38
+ - RSL1a, RSL1b [\#340](https://github.com/ably/ably-ruby/pull/340) ([lukaszsliwa](https://github.com/lukaszsliwa))
39
+ - Add support for RSA4b, b1, c, RSA16 \(Authentication\) [\#338](https://github.com/ably/ably-ruby/pull/338) ([lukaszsliwa](https://github.com/lukaszsliwa))
40
+ - ChannelOptions related tasks [\#336](https://github.com/ably/ably-ruby/pull/336) ([TheSmartnik](https://github.com/TheSmartnik))
41
+ - Update RSC7 [\#334](https://github.com/ably/ably-ruby/pull/334) ([TheSmartnik](https://github.com/TheSmartnik))
42
+
43
+ ## [v1.1.8](https://github.com/ably/ably-ruby/tree/v1.1.8)
44
+
45
+ [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.1.7...v1.1.8)
46
+
47
+ **Fixed bugs:**
48
+
49
+ - Lib apparently closing the socket after each request [\#211](https://github.com/ably/ably-ruby/issues/211)
50
+
51
+ **Closed issues:**
52
+
53
+ - Resolve config.around\(\) issue and upgrade rspec [\#313](https://github.com/ably/ably-ruby/issues/313)
54
+ - Write spec tests for RTL21 [\#308](https://github.com/ably/ably-ruby/issues/308)
55
+ - Write spec tests for RTL20 [\#307](https://github.com/ably/ably-ruby/issues/307)
56
+ - Write spec tests for RTL19, RTL19a, b, c [\#306](https://github.com/ably/ably-ruby/issues/306)
57
+ - Write spec tests for RTL18, RTL18a, b, c [\#305](https://github.com/ably/ably-ruby/issues/305)
58
+ - Add support for RTL20 [\#295](https://github.com/ably/ably-ruby/issues/295)
59
+ - Add support for RTL19, RTL19a, b, c [\#294](https://github.com/ably/ably-ruby/issues/294)
60
+ - Add support for RTL18, RTL18a, b, c [\#293](https://github.com/ably/ably-ruby/issues/293)
61
+ - Write spec tests for RSL6b, RLS7 \(Channels\) [\#284](https://github.com/ably/ably-ruby/issues/284)
62
+ - Write spec tests for RSC15e, d, f \(Host Fallback \)
63
+ [\#280](https://github.com/ably/ably-ruby/issues/280)
64
+ - Write spec tests for RSC7a, RSC7c \(RestClient\)
65
+ [\#279](https://github.com/ably/ably-ruby/issues/279)
66
+ - Add support for DataTypes ChannelOptions TB2c, d [\#278](https://github.com/ably/ably-ruby/issues/278)
67
+ - Add support for DataTypes TokenParams AO2g [\#277](https://github.com/ably/ably-ruby/issues/277)
68
+ - Add support for DataTypes ClientOptions TO3j10 [\#276](https://github.com/ably/ably-ruby/issues/276)
69
+ - Add support for DataTypes ErrorInfo TI1 [\#275](https://github.com/ably/ably-ruby/issues/275)
70
+ - Add support for DataTypes ProtocolMessage TR3f, TR4i, q [\#274](https://github.com/ably/ably-ruby/issues/274)
71
+ - Add support for TM2i \(DataTypes Message\) [\#273](https://github.com/ably/ably-ruby/issues/273)
72
+ - Add support for PC1, PC2, PC3, PC3a \(Plugins\) [\#272](https://github.com/ably/ably-ruby/issues/272)
73
+ - Add support for RSL6b, RLS7 \(Channels\) [\#271](https://github.com/ably/ably-ruby/issues/271)
74
+ - Add support for RSL1a, b, h, k1, k2, l, l1 \(Channels\) [\#270](https://github.com/ably/ably-ruby/issues/270)
75
+ - Add support for RSC15e, d, f \(Host Fallback \)
76
+ [\#267](https://github.com/ably/ably-ruby/issues/267)
77
+ - Update client options support to 1.1 spec level \(logExceptionReportingUrl\) [\#246](https://github.com/ably/ably-ruby/issues/246)
78
+ - Confirm status of remaining realtime spec items for 1.0 [\#244](https://github.com/ably/ably-ruby/issues/244)
79
+
80
+ **Merged pull requests:**
81
+
82
+ - Allowing ConnectionDetails\#max\_message\_size [\#342](https://github.com/ably/ably-ruby/pull/342) ([lukaszsliwa](https://github.com/lukaszsliwa))
83
+ - Add specs for RTL17 [\#335](https://github.com/ably/ably-ruby/pull/335) ([TheSmartnik](https://github.com/TheSmartnik))
84
+ - Add spec for RTP5b [\#332](https://github.com/ably/ably-ruby/pull/332) ([TheSmartnik](https://github.com/TheSmartnik))
85
+ - Update specs with comments to docs seciton for RSN3a/RSN3c [\#331](https://github.com/ably/ably-ruby/pull/331) ([TheSmartnik](https://github.com/TheSmartnik))
86
+ - Fix after suite hook in specs [\#329](https://github.com/ably/ably-ruby/pull/329) ([TheSmartnik](https://github.com/TheSmartnik))
87
+ - Add specs for RTN15h2 [\#328](https://github.com/ably/ably-ruby/pull/328) ([TheSmartnik](https://github.com/TheSmartnik))
88
+ - Add specs for RTN12f [\#327](https://github.com/ably/ably-ruby/pull/327) ([TheSmartnik](https://github.com/TheSmartnik))
89
+ - Added Channel\#set\_options and Channel\#options= aliases [\#326](https://github.com/ably/ably-ruby/pull/326) ([lukaszsliwa](https://github.com/lukaszsliwa))
90
+ - Added DeltaExtras class and Message\#delta\_extras method. \(TM2i\) [\#325](https://github.com/ably/ably-ruby/pull/325) ([lukaszsliwa](https://github.com/lukaszsliwa))
91
+ - When connection disconnectes and can't renew token it fails \(RTN15h1\) [\#324](https://github.com/ably/ably-ruby/pull/324) ([TheSmartnik](https://github.com/TheSmartnik))
92
+ - RTN-13c Add spec that channels do not reattach when connection isn't connected [\#323](https://github.com/ably/ably-ruby/pull/323) ([TheSmartnik](https://github.com/TheSmartnik))
93
+ - Add support for DataTypes ProtocolMessage: has\_attach\_resume\_flag? [\#322](https://github.com/ably/ably-ruby/pull/322) ([lukaszsliwa](https://github.com/lukaszsliwa))
94
+ - Added request\_id and cause attributes to the ErrorInfo class TI1, RSC7c [\#321](https://github.com/ably/ably-ruby/pull/321) ([lukaszsliwa](https://github.com/lukaszsliwa))
95
+ - Add spec for RTN12d [\#318](https://github.com/ably/ably-ruby/pull/318) ([TheSmartnik](https://github.com/TheSmartnik))
96
+ - Change behavior when reconnecting from failed state \(RTN11d\) [\#316](https://github.com/ably/ably-ruby/pull/316) ([TheSmartnik](https://github.com/TheSmartnik))
97
+ - Remove deprecated ProtocolMessage\#connection\_key TR4e [\#315](https://github.com/ably/ably-ruby/pull/315) ([TheSmartnik](https://github.com/TheSmartnik))
98
+ - Upgrade rspec to 3.10 [\#314](https://github.com/ably/ably-ruby/pull/314) ([lukaszsliwa](https://github.com/lukaszsliwa))
99
+ - Add a spec for \#RTN11c [\#257](https://github.com/ably/ably-ruby/pull/257) ([TheSmartnik](https://github.com/TheSmartnik))
100
+
101
+
3
102
  ## [v1.1.7](https://github.com/ably/ably-ruby/tree/v1.1.7)
4
103
 
5
104
  [Full Changelog](https://github.com/ably/ably-ruby/compare/v1.1.6...v1.1.7)
data/COPYRIGHT CHANGED
@@ -1 +1 @@
1
- Copyright 2015-2021 Ably Real-time Ltd (ably.com)
1
+ Copyright 2015-2022 Ably Real-time Ltd (ably.com)
data/README.md CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  _[Ably](https://ably.com) is the platform that powers synchronized digital experiences in realtime. Whether attending an event in a virtual venue, receiving realtime financial information, or monitoring live car performance data – consumers simply expect realtime digital experiences as standard. Ably provides a suite of APIs to build, extend, and deliver powerful digital experiences in realtime for more than 250 million devices across 80 countries each month. Organizations like Bloomberg, HubSpot, Verizon, and Hopin depend on Ably’s platform to offload the growing complexity of business-critical realtime data synchronization at global scale. For more information, see the [Ably documentation](https://ably.com/documentation)._
7
7
 
8
- This is a Ruby client library for Ably. The library currently targets the [Ably 1.1 client library specification](https://ably.com/documentation/client-lib-development-guide/features/). You can see the complete list of features this client library supports in [our client library SDKs feature support matrix](https://ably.com/download/sdk-feature-support-matrix).
8
+ This is a Ruby client library for Ably. The library currently targets the [Ably 1.2 client library specification](https://ably.com/documentation/client-lib-development-guide/features/). You can see the complete list of features this client library supports in [our client library SDKs feature support matrix](https://ably.com/download/sdk-feature-support-matrix).
9
9
 
10
10
  ## Supported platforms
11
11
 
12
- This SDK supports Ruby 1.9.3+. For eventmachine and Ruby 3.0 note please visit [Ruby 3.0 support](#ruby-30-support) section.
12
+ This SDK supports Ruby 2.7 and 3.x. For eventmachine and Ruby 3.x note please visit [Ruby 3.0 support](#ruby-30-support) section.
13
13
 
14
14
  As of v1.1.5 this library requires `libcurl` as a system dependency. On most systems this is already installed but in rare cases where it isn't (for example debian-slim Docker images such as ruby-slim) you will need to install it yourself. On debian you can install it with the command `sudo apt-get install libcurl4`.
15
15
 
data/SPEC.md CHANGED
@@ -3299,8 +3299,6 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
3299
3299
  * [retrieves attribute :channel_serial](./spec/shared/model_behaviour.rb#L15)
3300
3300
  * #connection_id
3301
3301
  * [retrieves attribute :connection_id](./spec/shared/model_behaviour.rb#L15)
3302
- * #connection_key
3303
- * [retrieves attribute :connection_key](./spec/shared/model_behaviour.rb#L15)
3304
3302
  * #==
3305
3303
  * [is true when attributes are the same](./spec/shared/model_behaviour.rb#L41)
3306
3304
  * [is false when attributes are not the same](./spec/shared/model_behaviour.rb#L46)
@@ -3386,11 +3384,6 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
3386
3384
  * [contains the attributes from the JSON auth details](./spec/unit/models/protocol_message_spec.rb#L358)
3387
3385
  * without a JSON value
3388
3386
  * [contains an empty AuthDetails object](./spec/unit/models/protocol_message_spec.rb#L366)
3389
- * #connection_key (#TR4e)
3390
- * existing only in #connection_details.connection_key
3391
- * [is returned](./spec/unit/models/protocol_message_spec.rb#L377)
3392
- * existing in both #connection_key and #connection_details.connection_key
3393
- * [returns #connection_details.connection_key as #connection_key will be deprecated > 0.8](./spec/unit/models/protocol_message_spec.rb#L385)
3394
3387
 
3395
3388
  ### Ably::Models::PushChannelSubscription
3396
3389
  _(see [spec/unit/models/push_channel_subscription_spec.rb](./spec/unit/models/push_channel_subscription_spec.rb))_
data/UPDATING.md ADDED
@@ -0,0 +1,30 @@
1
+ # Upgrade / Migration Guide
2
+
3
+ ## Version 1.1.8 to 1.2.0
4
+
5
+ ### Notable Changes
6
+ This release is all about channel options. Here is the full [changelog](https://github.com/ably/ably-ruby/blob/main/CHANGELOG.md)
7
+
8
+ * Channel options were extracted into a seperate model [ChannelOptions](https://github.com/ably/ably-ruby/blob/main/lib/ably/models/channel_options.rb). However it's still backward campatible with `Hash` and you don't need to do make any adjustments to your code
9
+
10
+ * The `ChannelOptions` class now supports `:params`, `:modes` and `:cipher` as options. Previously only `:cipher` was available
11
+
12
+ * The client `:idempotent_rest_publishing` option is `true` by default. Previously `:idempotent_rest_publishing` was `false` by default.
13
+
14
+ ### Breaking Changes
15
+
16
+ * Changing channel options with `Channels#get` is now deprecated in favor of explicit options change
17
+
18
+ 1. If channel state is attached or attaching an exception will be raised
19
+ 2. Otherwise the library will emit a warning
20
+
21
+ For example, the following code
22
+ ```
23
+ client.channels.get(channel_name, new_channel_options)
24
+ ```
25
+
26
+ Should be changed to:
27
+ ```
28
+ channel = client.channels.get(channel_name)
29
+ channel.options = new_channel_options
30
+ ```
data/ably.gemspec CHANGED
@@ -20,41 +20,28 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency 'eventmachine', '~> 1.2.6'
22
22
  spec.add_runtime_dependency 'em-http-request', '~> 1.1'
23
- spec.add_runtime_dependency 'statesman', '~> 8.0'
24
- spec.add_runtime_dependency 'faraday', '~> 1.0'
23
+ spec.add_runtime_dependency 'statesman', '~> 9.0'
24
+ spec.add_runtime_dependency 'faraday', '~> 2.2'
25
+ spec.add_runtime_dependency 'faraday-typhoeus', '~> 0.2.0'
25
26
  spec.add_runtime_dependency 'typhoeus', '~> 1.4'
26
-
27
- if RUBY_VERSION.match(/^1\./)
28
- spec.add_runtime_dependency 'json', '< 2.0'
29
- else
30
- spec.add_runtime_dependency 'json'
31
- end
27
+ spec.add_runtime_dependency 'json'
32
28
  spec.add_runtime_dependency 'websocket-driver', '~> 0.7'
33
29
  spec.add_runtime_dependency 'msgpack', '>= 1.3.0'
34
30
  spec.add_runtime_dependency 'addressable', '>= 2.0.0'
35
31
 
36
32
  spec.add_development_dependency 'rake', '~> 13.0'
37
33
  spec.add_development_dependency 'redcarpet', '~> 3.3'
38
- spec.add_development_dependency 'rspec', '~> 3.3.0' # version lock, see config.around(:example, :event_machine) in event_machine_helper.rb
34
+ spec.add_development_dependency 'rspec', '~> 3.11.0'
39
35
  spec.add_development_dependency 'rspec-retry', '~> 0.6'
40
36
  spec.add_development_dependency 'yard', '~> 0.9'
41
37
  spec.add_development_dependency 'rspec-instafail', '~> 1.0'
42
38
  spec.add_development_dependency 'bundler', '>= 1.3.0'
43
-
44
- if RUBY_VERSION.match(/^1\./)
45
- spec.add_development_dependency 'public_suffix', '~> 1.4.6' # Later versions do not support Ruby 1.9
46
- spec.add_development_dependency 'webmock', '2.2'
47
- spec.add_development_dependency 'parallel_tests', '~> 2.9.0'
48
- else
49
- spec.add_development_dependency 'webmock', '~> 3.11'
50
- spec.add_development_dependency 'simplecov', '~> 0.21.2'
51
- spec.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
52
- spec.add_development_dependency 'parallel_tests', '~> 3.7'
53
- if !RUBY_VERSION.match(/^2\.[0123]/)
54
- spec.add_development_dependency 'pry', '~> 0.14.1'
55
- spec.add_development_dependency 'pry-byebug', '~> 3.8.0'
56
- end
57
- end
39
+ spec.add_development_dependency 'webmock', '~> 3.11'
40
+ spec.add_development_dependency 'simplecov', '~> 0.21.2'
41
+ spec.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
42
+ spec.add_development_dependency 'parallel_tests', '~> 3.8'
43
+ spec.add_development_dependency 'pry', '~> 0.14.1'
44
+ spec.add_development_dependency 'pry-byebug', '~> 3.8.0'
58
45
 
59
46
  if RUBY_VERSION.match(/^3\./)
60
47
  spec.add_development_dependency 'webrick', '~> 1.7.0'
data/lib/ably/auth.rb CHANGED
@@ -5,9 +5,9 @@ require 'securerandom'
5
5
  require 'ably/rest/middleware/external_exceptions'
6
6
 
7
7
  module Ably
8
- # Auth is responsible for authentication with {https://www.ably.io Ably} using basic or token authentication
8
+ # Auth is responsible for authentication with {https://www.ably.com Ably} using basic or token authentication
9
9
  #
10
- # Find out more about Ably authentication at: https://www.ably.io/documentation/general/authentication/
10
+ # Find out more about Ably authentication at: https://www.ably.com/docs/general/authentication/
11
11
  #
12
12
  # @!attribute [r] client_id
13
13
  # @return [String] The provided client ID, used for identifying this client for presence purposes
@@ -35,7 +35,7 @@ module Ably
35
35
 
36
36
  API_KEY_REGEX = /^[\w-]{2,}\.[\w-]{2,}:[\w-]{2,}$/
37
37
 
38
- # Supported AuthOption keys, see https://www.ably.io/documentation/realtime/types#auth-options
38
+ # Supported AuthOption keys, see https://www.ably.com/docs/realtime/types#auth-options
39
39
  # TODO: Review client_id usage embedded incorrectly within AuthOptions.
40
40
  # This is legacy code to configure a client with a client_id from the ClientOptions
41
41
  # TODO: Review inclusion of use_token_auth, ttl, token_params in auth options
@@ -277,7 +277,7 @@ module Ably
277
277
  #
278
278
  # @param [Hash] token_params the token params used in the token request
279
279
  # @option token_params [String] :client_id A client ID to associate with this token. The generated token may be used to authenticate as this +client_id+
280
- # @option token_params [Integer] :ttl validity time in seconds for the requested {Ably::Models::TokenDetails}. Limits may apply, see {https://www.ably.io/documentation/other/authentication}
280
+ # @option token_params [Integer] :ttl validity time in seconds for the requested {Ably::Models::TokenDetails}. Limits may apply, see {https://www.ably.com/docs/general/authentication}
281
281
  # @option token_params [Hash] :capability canonicalised representation of the resource paths and associated operations
282
282
  # @option token_params [Time] :timestamp the time of the request
283
283
  # @option token_params [String] :nonce an unquoted, unescaped random string of at least 16 characters
@@ -285,7 +285,7 @@ module Ably
285
285
  # @param [Hash] auth_options the authentication options for the token request
286
286
  # @option auth_options [String] :key API key comprising the key name and key secret in a single string
287
287
  # @option auth_options [String] :client_id client ID identifying this connection to other clients (will use +client_id+ specified when library was instanced if provided)
288
- # @option auth_options [Boolean] :query_time when true will query the {https://www.ably.io Ably} system for the current time instead of using the local time
288
+ # @option auth_options [Boolean] :query_time when true will query the {https://www.ably.com Ably} system for the current time instead of using the local time
289
289
  # @option auth_options [Hash] :token_params convenience to pass in +token_params+ within the +auth_options+ argument, especially useful when setting default token_params in the client constructor
290
290
  #
291
291
  # @return [Models::TokenRequest]
@@ -510,11 +510,11 @@ module Ably
510
510
  end
511
511
 
512
512
  def authorize_when_necessary
513
- if current_token_details && !current_token_details.expired?
513
+ if current_token_details && !current_token_details.expired?(from: current_time)
514
514
  return current_token_details
515
- else
516
- authorize
517
515
  end
516
+
517
+ authorize
518
518
  end
519
519
 
520
520
  # Returns the current device clock time unless the
data/lib/ably/logger.rb CHANGED
@@ -7,9 +7,9 @@ module Ably
7
7
  extend Forwardable
8
8
 
9
9
  # @param client [Ably::Rest::Client,Ably::Realtime::Client] Rest or Realtime Ably client
10
- # @param log_level [Integer] {http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html Ruby Logger} log level
10
+ # @param log_level [Integer] {http://www.ruby-doc.org/stdlib-3.1.1/libdoc/logger/rdoc/Logger.html Ruby Logger} log level
11
11
  # @param custom_logger [nil,Object] A custom logger can optionally be used instead of the,
12
- # however it must provide a {http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html Ruby Logger} compatible interface.
12
+ # however it must provide a {http://www.ruby-doc.org/stdlib-3.1.1/libdoc/logger/rdoc/Logger.html Ruby Logger} compatible interface.
13
13
  #
14
14
  def initialize(client, log_level, custom_logger = nil)
15
15
  @client = client
@@ -24,7 +24,7 @@ module Ably
24
24
  @log_mutex = Mutex.new
25
25
  end
26
26
 
27
- # The logger used by this class, defaults to {http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html Ruby Logger}
27
+ # The logger used by this class, defaults to {http://www.ruby-doc.org/stdlib-3.1.1/libdoc/logger/rdoc/Logger.html Ruby Logger}
28
28
  # @return {Object,Logger}
29
29
  attr_reader :logger
30
30
 
@@ -32,7 +32,7 @@ module Ably
32
32
  # @return {nil,Object}
33
33
  attr_reader :custom_logger
34
34
 
35
- # The log level ranging from DEBUG to FATAL, refer to http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html
35
+ # The log level ranging from DEBUG to FATAL, refer to http://www.ruby-doc.org/stdlib-3.1.1/libdoc/logger/rdoc/Logger.html
36
36
  # @return {Integer}
37
37
  attr_reader :log_level
38
38
 
@@ -0,0 +1,97 @@
1
+ module Ably::Models
2
+ # Convert token details argument to a {ChannelOptions} object
3
+ #
4
+ # @param attributes (see #initialize)
5
+ #
6
+ # @return [ChannelOptions]
7
+ def self.ChannelOptions(attributes)
8
+ case attributes
9
+ when ChannelOptions
10
+ return attributes
11
+ else
12
+ ChannelOptions.new(attributes)
13
+ end
14
+ end
15
+
16
+ # Represents options of a channel
17
+ class ChannelOptions
18
+ extend Ably::Modules::Enum
19
+ extend Forwardable
20
+ include Ably::Modules::ModelCommon
21
+
22
+ MODES = ruby_enum('MODES',
23
+ presence: 0,
24
+ publish: 1,
25
+ subscribe: 2,
26
+ presence_subscribe: 3
27
+ )
28
+
29
+ attr_reader :attributes
30
+
31
+ alias_method :to_h, :attributes
32
+
33
+ def_delegators :attributes, :fetch, :size, :empty?
34
+ # Initialize a new ChannelOptions
35
+ #
36
+ # @option params [Hash] (TB2c) params (for realtime client libraries only) a of key/value pairs
37
+ # @option modes [Hash] modes (for realtime client libraries only) an array of ChannelMode
38
+ # @option cipher [Hash,Ably::Models::CipherParams] :cipher A hash of options or a {Ably::Models::CipherParams} to configure the encryption. *:key* is required, all other options are optional.
39
+ #
40
+ def initialize(attrs)
41
+ @attributes = IdiomaticRubyWrapper(attrs.clone)
42
+
43
+ attributes[:modes] = modes.to_a.map { |mode| Ably::Models::ChannelOptions::MODES[mode] } if modes
44
+ attributes[:cipher] = Ably::Models::CipherParams(cipher) if cipher
45
+ attributes.clone
46
+ end
47
+
48
+ # @!attribute cipher
49
+ #
50
+ # @return [CipherParams]
51
+ def cipher
52
+ attributes[:cipher]
53
+ end
54
+
55
+ # @!attribute params
56
+ #
57
+ # @return [Hash]
58
+ def params
59
+ attributes[:params].to_h
60
+ end
61
+
62
+ # @!attribute modes
63
+ #
64
+ # @return [Array<ChannelOptions::MODES>]
65
+ def modes
66
+ attributes[:modes]
67
+ end
68
+
69
+ # Converts modes to a bitfield that coresponds to ProtocolMessage#flags
70
+ #
71
+ # @return [Integer]
72
+ def modes_to_flags
73
+ modes.map { |mode| Ably::Models::ProtocolMessage::ATTACH_FLAGS_MAPPING[mode.to_sym] }.reduce(:|)
74
+ end
75
+
76
+ # @return [Hash]
77
+ # @api private
78
+ def set_params(hash)
79
+ attributes[:params] = hash
80
+ end
81
+
82
+ # Sets modes from ProtocolMessage#flags
83
+ #
84
+ # @return [Array<ChannelOptions::MODES>]
85
+ # @api private
86
+ def set_modes_from_flags(flags)
87
+ return unless flags
88
+
89
+ message_modes = MODES.select do |mode|
90
+ flag = Ably::Models::ProtocolMessage::ATTACH_FLAGS_MAPPING[mode.to_sym]
91
+ flags & flag == flag
92
+ end
93
+
94
+ attributes[:modes] = message_modes.map { |mode| Ably::Models::ChannelOptions::MODES[mode] }
95
+ end
96
+ end
97
+ end
@@ -21,6 +21,12 @@ module Ably::Models
21
21
  class ConnectionDetails
22
22
  include Ably::Modules::ModelCommon
23
23
 
24
+ # Max message size
25
+ MAX_MESSAGE_SIZE = 65536 # See spec TO3l8
26
+
27
+ # Max frame size
28
+ MAX_FRAME_SIZE = 524288 # See spec TO3l9
29
+
24
30
  # @param attributes [Hash]
25
31
  # @option attributes [String] :client_id contains the client ID assigned to the connection
26
32
  # @option attributes [String] :connection_key the connection secret key string that is used to resume a connection and its state
@@ -38,8 +44,8 @@ module Ably::Models
38
44
  self.attributes[duration_field] = (self.attributes[duration_field].to_f / 1000).round
39
45
  end
40
46
  end
41
- self.attributes[:max_message_size] ||= 65536
42
- self.attributes[:max_frame_size] ||= 524288
47
+ self.attributes[:max_message_size] ||= MAX_MESSAGE_SIZE
48
+ self.attributes[:max_frame_size] ||= MAX_FRAME_SIZE
43
49
  self.attributes.freeze
44
50
  end
45
51
 
@@ -0,0 +1,29 @@
1
+ module Ably::Models
2
+ #
3
+ # @!attribute [r] from
4
+ # @return [String] The id of the message the delta was generated from
5
+ # @!attribute [r] format
6
+ # @return [String] The delta format. Only vcdiff is supported as at API version 1.2
7
+ #
8
+ class DeltaExtras
9
+ include Ably::Modules::ModelCommon
10
+
11
+ # The id of the message the delta was generated from.
12
+ # @return [String, nil]
13
+ #
14
+ attr_reader :from
15
+
16
+ # The delta format.
17
+ # @return [String, nil]
18
+ #
19
+ attr_reader :format
20
+
21
+ def initialize(attributes = {})
22
+ @from, @format = IdiomaticRubyWrapper((attributes || {}), stop_at: [:from, :format]).attributes.values_at(:from, :format)
23
+ end
24
+
25
+ def to_json(*args)
26
+ as_json(args).to_json
27
+ end
28
+ end
29
+ end
@@ -27,7 +27,7 @@ module Ably::Models
27
27
  # @!attribute [r] form_factor
28
28
  # @return [String] Device form factor such as phone, tablet, watch
29
29
  # @!attribute [r] client_id
30
- # @return [String] The authenticated client identifier for this device. See {https://www.ably.io/documentation/general/authentication#identified-clients auth documentation}.
30
+ # @return [String] The authenticated client identifier for this device. See {https://www.ably.com/docs/general/authentication#identified-clients auth documentation}.
31
31
  # @!attribute [r] metadata
32
32
  # @return [Hash] Arbitrary metadata that can be associated with a device
33
33
  # @!attribute [r] device_secret
@@ -27,6 +27,10 @@ module Ably::Models
27
27
  # @return [Integer] Ably error code (see ably-common/protocol/errors.json)
28
28
  # @!attribute [r] status
29
29
  # @return [Integer] HTTP Status Code corresponding to this error, where applicable
30
+ # @!attribute [r] request_id
31
+ # @return [Integer] HTTP RequestId corresponding to this error, where applicable (#RSC7c)
32
+ # @!attribute [r] cause
33
+ # @return [Integer] HTTP Status Code corresponding to this error, where applicable (#TI1)
30
34
  # @!attribute [r] attributes
31
35
  # @return [Hash] Access the protocol message Hash object ruby'fied to use symbolized keys
32
36
  #
@@ -38,7 +42,7 @@ module Ably::Models
38
42
  @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze)
39
43
  end
40
44
 
41
- %w(message code href status_code).each do |attribute|
45
+ %w(message code href status_code request_id cause).each do |attribute|
42
46
  define_method attribute do
43
47
  attributes[attribute.to_sym]
44
48
  end
@@ -52,7 +56,7 @@ module Ably::Models
52
56
  def to_s
53
57
  error_href = href || (code ? "https://help.ably.io/error/#{code}" : '')
54
58
  see_msg = " -> see #{error_href} for help" unless message.to_s.include?(error_href.to_s)
55
- "<Error: #{message} (code: #{code}, http status: #{status})>#{see_msg}"
59
+ "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
56
60
  end
57
61
  end
58
62
  end
@@ -94,6 +94,10 @@ module Ably::Models
94
94
  attributes.size
95
95
  end
96
96
 
97
+ def empty?
98
+ attributes.empty?
99
+ end
100
+
97
101
  def keys
98
102
  map { |key, value| key }
99
103
  end
@@ -142,6 +142,9 @@ module Ably::Models
142
142
 
143
143
  # Contains any arbitrary key value pairs which may also contain other primitive JSON types, JSON-encodable objects or JSON-encodable arrays.
144
144
  # The extras field is provided to contain message metadata and/or ancillary payloads in support of specific functionality, e.g. push
145
+ # 1.2 adds the delta extension which is of type DeltaExtras, and the headers extension, which contains arbitrary string->string key-value pairs,
146
+ # settable at publish time. Unless otherwise specified, the client library should not attempt to do any filtering or validation of the extras
147
+ # field itself, but should treat it opaquely, encoding it and passing it to realtime unaltered.
145
148
  # @api private
146
149
  def extras
147
150
  attributes[:extras].tap do |val|
@@ -151,15 +154,23 @@ module Ably::Models
151
154
  end
152
155
  end
153
156
 
154
- private
155
- def raw_hash_object
156
- @raw_hash_object
157
+ # Delta extras extension (TM2i)
158
+ # @return [DeltaExtras, nil]
159
+ # @api private
160
+ def delta_extras
161
+ return nil if attributes[:extras][:delta].nil?
162
+ @delta_extras ||= DeltaExtras.new(attributes[:extras][:delta]).freeze
157
163
  end
158
164
 
159
165
  def protocol_message_index
160
166
  protocol_message.messages.map(&:object_id).index(self.object_id)
161
167
  end
162
168
 
169
+ private
170
+ def raw_hash_object
171
+ @raw_hash_object
172
+ end
173
+
163
174
  def set_attributes_object(new_attributes)
164
175
  @attributes = IdiomaticRubyWrapper(new_attributes.clone, stop_at: [:data, :extras])
165
176
  end