ably 0.7.6 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -7
  3. data/SPEC.md +310 -269
  4. data/lib/ably/auth.rb +177 -127
  5. data/lib/ably/models/presence_message.rb +1 -1
  6. data/lib/ably/models/protocol_message.rb +1 -2
  7. data/lib/ably/models/token_details.rb +101 -0
  8. data/lib/ably/models/token_request.rb +108 -0
  9. data/lib/ably/modules/http_helpers.rb +1 -1
  10. data/lib/ably/realtime.rb +2 -6
  11. data/lib/ably/realtime/channel.rb +14 -8
  12. data/lib/ably/realtime/client.rb +2 -6
  13. data/lib/ably/realtime/connection.rb +4 -2
  14. data/lib/ably/rest.rb +2 -6
  15. data/lib/ably/rest/channel.rb +10 -6
  16. data/lib/ably/rest/client.rb +15 -16
  17. data/lib/ably/rest/presence.rb +12 -10
  18. data/lib/ably/version.rb +1 -1
  19. data/spec/acceptance/realtime/client_spec.rb +15 -15
  20. data/spec/acceptance/realtime/connection_failures_spec.rb +3 -3
  21. data/spec/acceptance/realtime/connection_spec.rb +9 -9
  22. data/spec/acceptance/rest/auth_spec.rb +248 -172
  23. data/spec/acceptance/rest/base_spec.rb +8 -6
  24. data/spec/acceptance/rest/channel_spec.rb +9 -2
  25. data/spec/acceptance/rest/client_spec.rb +21 -21
  26. data/spec/acceptance/rest/presence_spec.rb +12 -5
  27. data/spec/acceptance/rest/stats_spec.rb +4 -4
  28. data/spec/rspec_config.rb +3 -2
  29. data/spec/shared/client_initializer_behaviour.rb +21 -24
  30. data/spec/support/api_helper.rb +3 -3
  31. data/spec/support/test_app.rb +9 -9
  32. data/spec/unit/auth_spec.rb +17 -0
  33. data/spec/unit/models/token_details_spec.rb +111 -0
  34. data/spec/unit/models/token_request_spec.rb +110 -0
  35. data/spec/unit/rest/client_spec.rb +1 -1
  36. metadata +8 -5
  37. data/lib/ably/models/token.rb +0 -74
  38. data/spec/unit/models/token_spec.rb +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcbdc60f16510edf0fa8a6dd96f142d1b507341c
4
- data.tar.gz: a4f451ae9f096f4b91f29c493f5985278f5fa6c6
3
+ metadata.gz: ba39382980b1eaf4c268537ad21ec47ba6bdedce
4
+ data.tar.gz: aaf3e7fc98ad08113e67eaaf7b11913d7422427b
5
5
  SHA512:
6
- metadata.gz: a7f1794e98c16a94d8e1fa3790c82ae3ca5852a4d8e14832366eb45195e620c0728f4b41c21ff20159e30c0b783c0ae39af2caeefc427cf1584be0ad79eb5345
7
- data.tar.gz: 6401e4ecbd7aa85609d1568998be4689f7ff340966471111c74a8d5f35ad2e3c93a4cf4121b291022a3b8cc857227f683711ee31d36dd1170c94ac7cd706495e
6
+ metadata.gz: 0a4a82b3a6db3d81d8632af1d14752c2d2f71559409718406d359541ffa495fa0296d4fd3a2853148eec093a1ad412b86252748a8c4f5b964508dc345a8aabe5
7
+ data.tar.gz: 781fb7c47db94d7c85fdbfc3e6839f277a436fff6ed13b915aee0f735b0b17bfab982be6e01cfcd7bc0d99248b8b479757a55effe834c16ba8ef22a2f74e283e
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
- # [Ably](https://ably.io)
1
+ # [Ably](https://www.ably.io)
2
2
 
3
3
  [![Build Status](https://travis-ci.org/ably/ably-ruby.png)](https://travis-ci.org/ably/ably-ruby)
4
4
  [![Gem Version](https://badge.fury.io/rb/ably.svg)](http://badge.fury.io/rb/ably)
5
5
  [![Coverage Status](https://coveralls.io/repos/ably/ably-ruby/badge.svg)](https://coveralls.io/r/ably/ably-ruby)
6
6
 
7
- A Ruby client library for [ably.io](https://ably.io), the realtime messaging service.
7
+ A Ruby client library for [ably.io](https://www.ably.io), the realtime messaging service.
8
8
 
9
9
  ## Documentation
10
10
 
11
- Visit https://ably.io/documentation for a complete API reference and more examples.
11
+ Visit https://www.ably.io/documentation for a complete API reference and more examples.
12
12
 
13
13
  ## Installation
14
14
 
@@ -41,7 +41,11 @@ end
41
41
  All examples assume a client has been created as follows:
42
42
 
43
43
  ```ruby
44
+ # basic auth with an API key
44
45
  client = Ably::Realtime.new(key: 'xxxxx')
46
+
47
+ # using token auth
48
+ client = Ably::Realtime.new(token: 'xxxxx')
45
49
  ```
46
50
 
47
51
  ### Connection
@@ -178,8 +182,10 @@ presence_page.next # retrieves the next page => #<Ably::Models::PaginatedResourc
178
182
  ### Generate Token and Token Request
179
183
 
180
184
  ```ruby
181
- client.auth.request_token
182
- # => #<Ably::Models::Token ...>
185
+ token_details = client.auth.request_token
186
+ # => #<Ably::Models::TokenDetails ...>
187
+ token_details.token # => "xVLyHw.CLchevH3hF....MDh9ZC_Q"
188
+ client = Ably::Rest.new(token: token_details.token)
183
189
 
184
190
  token = client.auth.create_token_request
185
191
  # => {"id"=>...,
@@ -189,8 +195,6 @@ token = client.auth.create_token_request
189
195
  # "capability"=>"{\"*\":[\"*\"]}",
190
196
  # "nonce"=>...,
191
197
  # "mac"=>...}
192
-
193
- client = Ably::Rest.new(token_id: token.id)
194
198
  ```
195
199
 
196
200
  ### Fetching your application's stats
data/SPEC.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ably Realtime & REST Client Library 0.7.5 Specification
1
+ # Ably Realtime & REST Client Library 0.8.0 Specification
2
2
 
3
3
  ### Ably::Realtime::Channel#history
4
4
  _(see [spec/acceptance/realtime/channel_history_spec.rb](./spec/acceptance/realtime/channel_history_spec.rb))_
@@ -115,22 +115,22 @@ _(see [spec/acceptance/realtime/client_spec.rb](./spec/acceptance/realtime/clien
115
115
  * [fails to connect because a private key cannot be sent over a non-secure connection](./spec/acceptance/realtime/client_spec.rb#L31)
116
116
  * token auth
117
117
  * with TLS enabled
118
- * and a pre-generated Token provided with the :token_id option
118
+ * and a pre-generated Token provided with the :token option
119
119
  * [connects using token auth](./spec/acceptance/realtime/client_spec.rb#L51)
120
120
  * with valid :key and :use_token_auth option set to true
121
121
  * [automatically authorises on connect and generates a token](./spec/acceptance/realtime/client_spec.rb#L64)
122
122
  * with client_id
123
123
  * [connects using token auth](./spec/acceptance/realtime/client_spec.rb#L77)
124
124
  * with TLS disabled
125
- * and a pre-generated Token provided with the :token_id option
125
+ * and a pre-generated Token provided with the :token option
126
126
  * [connects using token auth](./spec/acceptance/realtime/client_spec.rb#L51)
127
127
  * with valid :key and :use_token_auth option set to true
128
128
  * [automatically authorises on connect and generates a token](./spec/acceptance/realtime/client_spec.rb#L64)
129
129
  * with client_id
130
130
  * [connects using token auth](./spec/acceptance/realtime/client_spec.rb#L77)
131
- * with token_request_block
132
- * [calls the block](./spec/acceptance/realtime/client_spec.rb#L102)
133
- * [uses the token request when requesting a new token](./spec/acceptance/realtime/client_spec.rb#L109)
131
+ * with a Proc for the :auth_callback option
132
+ * [calls the Proc](./spec/acceptance/realtime/client_spec.rb#L102)
133
+ * [uses the token request returned from the callback when requesting a new token](./spec/acceptance/realtime/client_spec.rb#L109)
134
134
 
135
135
  ### Ably::Realtime::Connection failures
136
136
  _(see [spec/acceptance/realtime/connection_failures_spec.rb](./spec/acceptance/realtime/connection_failures_spec.rb))_
@@ -139,7 +139,7 @@ _(see [spec/acceptance/realtime/connection_failures_spec.rb](./spec/acceptance/r
139
139
  * when API key is invalid
140
140
  * with invalid app part of the key
141
141
  * [enters the failed state and returns a not found error](./spec/acceptance/realtime/connection_failures_spec.rb#L26)
142
- * with invalid key ID part of the key
142
+ * with invalid key name part of the key
143
143
  * [enters the failed state and returns an authorization error](./spec/acceptance/realtime/connection_failures_spec.rb#L40)
144
144
  * automatic connection retry
145
145
  * with invalid WebSocket host
@@ -603,116 +603,118 @@ _(see [spec/acceptance/rest/auth_spec.rb](./spec/acceptance/rest/auth_spec.rb))_
603
603
  * using JSON and MsgPack protocol
604
604
  * [has immutable options](./spec/acceptance/rest/auth_spec.rb#L54)
605
605
  * #request_token
606
- * [returns a valid requested token in the expected format with valid issued_at and expires_at attributes](./spec/acceptance/rest/auth_spec.rb#L69)
606
+ * [returns a valid requested token in the expected format with valid issued and expires attributes](./spec/acceptance/rest/auth_spec.rb#L69)
607
607
  * with option :client_id
608
- * [overrides default and uses camelCase notation for all attributes](./spec/acceptance/rest/auth_spec.rb#L95)
608
+ * [overrides default and uses camelCase notation for attributes](./spec/acceptance/rest/auth_spec.rb#L100)
609
609
  * with option :capability
610
- * [overrides default and uses camelCase notation for all attributes](./spec/acceptance/rest/auth_spec.rb#L95)
610
+ * [overrides default and uses camelCase notation for attributes](./spec/acceptance/rest/auth_spec.rb#L100)
611
611
  * with option :nonce
612
- * [overrides default and uses camelCase notation for all attributes](./spec/acceptance/rest/auth_spec.rb#L95)
612
+ * [overrides default and uses camelCase notation for attributes](./spec/acceptance/rest/auth_spec.rb#L100)
613
613
  * with option :timestamp
614
- * [overrides default and uses camelCase notation for all attributes](./spec/acceptance/rest/auth_spec.rb#L95)
614
+ * [overrides default and uses camelCase notation for attributes](./spec/acceptance/rest/auth_spec.rb#L100)
615
615
  * with option :ttl
616
- * [overrides default and uses camelCase notation for all attributes](./spec/acceptance/rest/auth_spec.rb#L95)
617
- * with :key_id & :key_secret options
618
- * [key_id is used in request and signing uses key_secret](./spec/acceptance/rest/auth_spec.rb#L124)
616
+ * [overrides default and uses camelCase notation for attributes](./spec/acceptance/rest/auth_spec.rb#L100)
617
+ * with :key option
618
+ * [key_name is used in request and signing uses key_secret](./spec/acceptance/rest/auth_spec.rb#L129)
619
+ * with :key_name & :key_secret options
620
+ * [key_name is used in request and signing uses key_secret](./spec/acceptance/rest/auth_spec.rb#L158)
619
621
  * with :query_time option
620
- * [queries the server for the time](./spec/acceptance/rest/auth_spec.rb#L132)
622
+ * [queries the server for the time](./spec/acceptance/rest/auth_spec.rb#L166)
621
623
  * without :query_time option
622
- * [does not query the server for the time](./spec/acceptance/rest/auth_spec.rb#L141)
624
+ * [does not query the server for the time](./spec/acceptance/rest/auth_spec.rb#L175)
623
625
  * with :auth_url option
624
626
  * when response from :auth_url is a valid token request
625
- * [requests a token from :auth_url using an HTTP GET request](./spec/acceptance/rest/auth_spec.rb#L188)
626
- * [returns a valid token generated from the token request](./spec/acceptance/rest/auth_spec.rb#L193)
627
+ * [requests a token from :auth_url using an HTTP GET request](./spec/acceptance/rest/auth_spec.rb#L223)
628
+ * [returns a valid token generated from the token request](./spec/acceptance/rest/auth_spec.rb#L228)
627
629
  * with :query_params
628
- * [requests a token from :auth_url with the :query_params](./spec/acceptance/rest/auth_spec.rb#L200)
630
+ * [requests a token from :auth_url with the :query_params](./spec/acceptance/rest/auth_spec.rb#L235)
629
631
  * with :headers
630
- * [requests a token from :auth_url with the HTTP headers set](./spec/acceptance/rest/auth_spec.rb#L208)
632
+ * [requests a token from :auth_url with the HTTP headers set](./spec/acceptance/rest/auth_spec.rb#L243)
631
633
  * with POST
632
- * [requests a token from :auth_url using an HTTP POST instead of the default GET](./spec/acceptance/rest/auth_spec.rb#L216)
633
- * when response from :auth_url is a token
634
- * [returns a Token created from the token JSON](./spec/acceptance/rest/auth_spec.rb#L240)
634
+ * [requests a token from :auth_url using an HTTP POST instead of the default GET](./spec/acceptance/rest/auth_spec.rb#L251)
635
+ * when response from :auth_url is a token details object
636
+ * [returns TokenDetails created from the token JSON](./spec/acceptance/rest/auth_spec.rb#L276)
637
+ * when response from :auth_url is text/plain content type and a token string
638
+ * [returns TokenDetails created from the token JSON](./spec/acceptance/rest/auth_spec.rb#L293)
635
639
  * when response is invalid
636
640
  * 500
637
- * [raises ServerError](./spec/acceptance/rest/auth_spec.rb#L255)
641
+ * [raises ServerError](./spec/acceptance/rest/auth_spec.rb#L306)
638
642
  * XML
639
- * [raises InvalidResponseBody](./spec/acceptance/rest/auth_spec.rb#L266)
640
- * with token_request_block that returns a token request
641
- * [calls the block when authenticating to obtain the request token](./spec/acceptance/rest/auth_spec.rb#L284)
642
- * [uses the token request from the block when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L289)
643
- * with token_request_block that returns a token
644
- * [calls the block when authenticating to obtain the request token](./spec/acceptance/rest/auth_spec.rb#L317)
645
- * [uses the token request from the block when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L322)
643
+ * [raises InvalidResponseBody](./spec/acceptance/rest/auth_spec.rb#L317)
644
+ * with a Proc for the :auth_callback option
645
+ * that returns a TokenRequest
646
+ * [calls the Proc when authenticating to obtain the request token](./spec/acceptance/rest/auth_spec.rb#L336)
647
+ * [uses the token request returned from the callback when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L341)
648
+ * that returns a TokenDetails JSON object
649
+ * [calls the Proc when authenticating to obtain the request token](./spec/acceptance/rest/auth_spec.rb#L370)
650
+ * [uses the token request returned from the callback when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L375)
651
+ * that returns a TokenDetails object
652
+ * [uses the token request returned from the callback when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L396)
653
+ * that returns a Token string
654
+ * [uses the token request returned from the callback when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L412)
646
655
  * with client_id
647
- * [returns a token with the client_id](./spec/acceptance/rest/auth_spec.rb#L357)
656
+ * [returns a token with the client_id](./spec/acceptance/rest/auth_spec.rb#L444)
648
657
  * before #authorise has been called
649
- * [has no current_token](./spec/acceptance/rest/auth_spec.rb#L364)
658
+ * [has no current_token_details](./spec/acceptance/rest/auth_spec.rb#L451)
650
659
  * #authorise
651
- * [updates the persisted auth options thare are then used for subsequent authorise requests](./spec/acceptance/rest/auth_spec.rb#L411)
660
+ * [updates the persisted auth options that are then used for subsequent authorise requests](./spec/acceptance/rest/auth_spec.rb#L498)
652
661
  * when called for the first time since the client has been instantiated
653
- * [passes all options to #request_token](./spec/acceptance/rest/auth_spec.rb#L375)
654
- * [returns a valid token](./spec/acceptance/rest/auth_spec.rb#L380)
655
- * [issues a new token if option :force => true](./spec/acceptance/rest/auth_spec.rb#L384)
662
+ * [passes all options to #request_token](./spec/acceptance/rest/auth_spec.rb#L462)
663
+ * [returns a valid token](./spec/acceptance/rest/auth_spec.rb#L467)
664
+ * [issues a new token if option :force => true](./spec/acceptance/rest/auth_spec.rb#L471)
656
665
  * with previous authorisation
657
- * [does not request a token if current_token has not expired](./spec/acceptance/rest/auth_spec.rb#L395)
658
- * [requests a new token if token is expired](./spec/acceptance/rest/auth_spec.rb#L400)
659
- * [issues a new token if option :force => true](./spec/acceptance/rest/auth_spec.rb#L406)
660
- * with token_request_block
661
- * [calls the block](./spec/acceptance/rest/auth_spec.rb#L427)
662
- * [uses the token request returned from the block when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L431)
666
+ * [does not request a token if current_token_details has not expired](./spec/acceptance/rest/auth_spec.rb#L482)
667
+ * [requests a new token if token is expired](./spec/acceptance/rest/auth_spec.rb#L487)
668
+ * [issues a new token if option :force => true](./spec/acceptance/rest/auth_spec.rb#L493)
669
+ * with a Proc for the :auth_callback option
670
+ * [calls the Proc](./spec/acceptance/rest/auth_spec.rb#L514)
671
+ * [uses the token request returned from the callback when requesting a new token](./spec/acceptance/rest/auth_spec.rb#L518)
663
672
  * for every subsequent #request_token
664
- * without a provided block
665
- * [calls the originally provided block](./spec/acceptance/rest/auth_spec.rb#L437)
673
+ * without a :auth_callback Proc
674
+ * [calls the originally provided block](./spec/acceptance/rest/auth_spec.rb#L524)
666
675
  * with a provided block
667
- * [does not call the originally provided block and calls the new #request_token block](./spec/acceptance/rest/auth_spec.rb#L444)
676
+ * [does not call the originally provided Proc and calls the new #request_token :auth_callback Proc](./spec/acceptance/rest/auth_spec.rb#L531)
668
677
  * #create_token_request
669
- * [uses the key ID from the client](./spec/acceptance/rest/auth_spec.rb#L460)
670
- * [uses the default TTL](./spec/acceptance/rest/auth_spec.rb#L464)
671
- * [uses the default capability](./spec/acceptance/rest/auth_spec.rb#L468)
678
+ * [uses the key name from the client](./spec/acceptance/rest/auth_spec.rb#L547)
679
+ * [uses the default TTL](./spec/acceptance/rest/auth_spec.rb#L551)
680
+ * [uses the default capability](./spec/acceptance/rest/auth_spec.rb#L555)
672
681
  * the nonce
673
- * [is unique for every request](./spec/acceptance/rest/auth_spec.rb#L473)
674
- * [is at least 16 characters](./spec/acceptance/rest/auth_spec.rb#L478)
682
+ * [is unique for every request](./spec/acceptance/rest/auth_spec.rb#L560)
683
+ * [is at least 16 characters](./spec/acceptance/rest/auth_spec.rb#L565)
675
684
  * with option :ttl
676
- * [overrides default](./spec/acceptance/rest/auth_spec.rb#L489)
677
- * with option :capability
678
- * [overrides default](./spec/acceptance/rest/auth_spec.rb#L489)
685
+ * [overrides default](./spec/acceptance/rest/auth_spec.rb#L576)
679
686
  * with option :nonce
680
- * [overrides default](./spec/acceptance/rest/auth_spec.rb#L489)
681
- * with option :timestamp
682
- * [overrides default](./spec/acceptance/rest/auth_spec.rb#L489)
687
+ * [overrides default](./spec/acceptance/rest/auth_spec.rb#L576)
683
688
  * with option :client_id
684
- * [overrides default](./spec/acceptance/rest/auth_spec.rb#L489)
689
+ * [overrides default](./spec/acceptance/rest/auth_spec.rb#L576)
685
690
  * with additional invalid attributes
686
- * [are ignored](./spec/acceptance/rest/auth_spec.rb#L497)
691
+ * [are ignored](./spec/acceptance/rest/auth_spec.rb#L584)
687
692
  * when required fields are missing
688
- * [should raise an exception if key secret is missing](./spec/acceptance/rest/auth_spec.rb#L508)
689
- * [should raise an exception if key id is missing](./spec/acceptance/rest/auth_spec.rb#L512)
693
+ * [should raise an exception if key secret is missing](./spec/acceptance/rest/auth_spec.rb#L595)
694
+ * [should raise an exception if key name is missing](./spec/acceptance/rest/auth_spec.rb#L599)
690
695
  * with :query_time option
691
- * [queries the server for the timestamp](./spec/acceptance/rest/auth_spec.rb#L521)
696
+ * [queries the server for the timestamp](./spec/acceptance/rest/auth_spec.rb#L608)
692
697
  * with :timestamp option
693
- * [uses the provided timestamp in the token request](./spec/acceptance/rest/auth_spec.rb#L531)
698
+ * [uses the provided timestamp in the token request](./spec/acceptance/rest/auth_spec.rb#L618)
694
699
  * signing
695
- * [generates a valid HMAC](./spec/acceptance/rest/auth_spec.rb#L548)
700
+ * [generates a valid HMAC](./spec/acceptance/rest/auth_spec.rb#L640)
696
701
  * using token authentication
697
- * with :token_id option
698
- * [authenticates successfully using the provided :token_id](./spec/acceptance/rest/auth_spec.rb#L571)
699
- * [disallows publishing on unspecified capability channels](./spec/acceptance/rest/auth_spec.rb#L575)
700
- * [fails if timestamp is invalid](./spec/acceptance/rest/auth_spec.rb#L583)
701
- * [cannot be renewed automatically](./spec/acceptance/rest/auth_spec.rb#L591)
702
+ * with :token option
703
+ * [authenticates successfully using the provided :token](./spec/acceptance/rest/auth_spec.rb#L663)
704
+ * [disallows publishing on unspecified capability channels](./spec/acceptance/rest/auth_spec.rb#L667)
705
+ * [fails if timestamp is invalid](./spec/acceptance/rest/auth_spec.rb#L675)
706
+ * [cannot be renewed automatically](./spec/acceptance/rest/auth_spec.rb#L683)
702
707
  * when implicit as a result of using :client id
703
708
  * and requests to the Ably server are mocked
704
- * [will send a token request to the server](./spec/acceptance/rest/auth_spec.rb#L621)
709
+ * [will send a token request to the server](./spec/acceptance/rest/auth_spec.rb#L711)
705
710
  * a token is created
706
- * [before a request is made](./spec/acceptance/rest/auth_spec.rb#L630)
707
- * [when a message is published](./spec/acceptance/rest/auth_spec.rb#L634)
708
- * [with capability and TTL defaults](./spec/acceptance/rest/auth_spec.rb#L638)
711
+ * [before a request is made](./spec/acceptance/rest/auth_spec.rb#L720)
712
+ * [when a message is published](./spec/acceptance/rest/auth_spec.rb#L724)
713
+ * [with capability and TTL defaults](./spec/acceptance/rest/auth_spec.rb#L728)
709
714
  * when using an :key and basic auth
710
- * [#using_token_auth? is false](./spec/acceptance/rest/auth_spec.rb#L653)
711
- * [#key attribute contains the key string](./spec/acceptance/rest/auth_spec.rb#L657)
712
- * [#using_basic_auth? is true](./spec/acceptance/rest/auth_spec.rb#L661)
713
- * when using legacy :api_key option and basic auth
714
- * [#using_token_auth? is false](./spec/acceptance/rest/auth_spec.rb#L671)
715
- * [#key attribute contains the key string](./spec/acceptance/rest/auth_spec.rb#L675)
715
+ * [#using_token_auth? is false](./spec/acceptance/rest/auth_spec.rb#L743)
716
+ * [#key attribute contains the key string](./spec/acceptance/rest/auth_spec.rb#L747)
717
+ * [#using_basic_auth? is true](./spec/acceptance/rest/auth_spec.rb#L751)
716
718
 
717
719
  ### Ably::Rest
718
720
  _(see [spec/acceptance/rest/base_spec.rb](./spec/acceptance/rest/base_spec.rb))_
@@ -739,7 +741,7 @@ _(see [spec/acceptance/rest/base_spec.rb](./spec/acceptance/rest/base_spec.rb))_
739
741
  * when auth#token_renewable?
740
742
  * [should automatically reissue a token](./spec/acceptance/rest/base_spec.rb#L143)
741
743
  * when NOT auth#token_renewable?
742
- * [should raise an InvalidToken exception](./spec/acceptance/rest/base_spec.rb#L156)
744
+ * [should raise an InvalidToken exception](./spec/acceptance/rest/base_spec.rb#L158)
743
745
 
744
746
  ### Ably::Rest::Channel
745
747
  _(see [spec/acceptance/rest/channel_spec.rb](./spec/acceptance/rest/channel_spec.rb))_
@@ -756,14 +758,14 @@ _(see [spec/acceptance/rest/channel_spec.rb](./spec/acceptance/rest/channel_spec
756
758
  * #history option
757
759
  * :start
758
760
  * with milliseconds since epoch value
759
- * [uses this value in the history request](./spec/acceptance/rest/channel_spec.rb#L116)
761
+ * [uses this value in the history request](./spec/acceptance/rest/channel_spec.rb#L123)
760
762
  * with a Time object value
761
- * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/channel_spec.rb#L126)
763
+ * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/channel_spec.rb#L133)
762
764
  * :end
763
765
  * with milliseconds since epoch value
764
- * [uses this value in the history request](./spec/acceptance/rest/channel_spec.rb#L116)
766
+ * [uses this value in the history request](./spec/acceptance/rest/channel_spec.rb#L123)
765
767
  * with a Time object value
766
- * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/channel_spec.rb#L126)
768
+ * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/channel_spec.rb#L133)
767
769
 
768
770
  ### Ably::Rest::Channels
769
771
  _(see [spec/acceptance/rest/channels_spec.rb](./spec/acceptance/rest/channels_spec.rb))_
@@ -785,43 +787,43 @@ _(see [spec/acceptance/rest/channels_spec.rb](./spec/acceptance/rest/channels_sp
785
787
  _(see [spec/acceptance/rest/client_spec.rb](./spec/acceptance/rest/client_spec.rb))_
786
788
  * using JSON and MsgPack protocol
787
789
  * #initialize
788
- * with an auth block
789
- * [calls the block to get a new token](./spec/acceptance/rest/client_spec.rb#L20)
790
+ * with a :auth_callback Proc
791
+ * [calls the auth Proc to get a new token](./spec/acceptance/rest/client_spec.rb#L20)
790
792
  * with an auth URL
791
793
  * [sends an HTTP request to the provided URL to get a new token](./spec/acceptance/rest/client_spec.rb#L34)
792
794
  * using tokens
793
795
  * when expired
794
- * [creates a new token automatically when the old token expires](./spec/acceptance/rest/client_spec.rb#L55)
796
+ * [creates a new token automatically when the old token expires](./spec/acceptance/rest/client_spec.rb#L58)
795
797
  * when token has not expired
796
- * [reuses the existing token for every request](./spec/acceptance/rest/client_spec.rb#L69)
798
+ * [reuses the existing token for every request](./spec/acceptance/rest/client_spec.rb#L72)
797
799
  * connection transport
798
800
  * for default host
799
- * [is configured to timeout connection opening in 4 seconds](./spec/acceptance/rest/client_spec.rb#L85)
800
- * [is configured to timeout connection requests in 15 seconds](./spec/acceptance/rest/client_spec.rb#L89)
801
+ * [is configured to timeout connection opening in 4 seconds](./spec/acceptance/rest/client_spec.rb#L88)
802
+ * [is configured to timeout connection requests in 15 seconds](./spec/acceptance/rest/client_spec.rb#L92)
801
803
  * for the fallback hosts
802
- * [is configured to timeout connection opening in 4 seconds](./spec/acceptance/rest/client_spec.rb#L95)
803
- * [is configured to timeout connection requests in 15 seconds](./spec/acceptance/rest/client_spec.rb#L99)
804
+ * [is configured to timeout connection opening in 4 seconds](./spec/acceptance/rest/client_spec.rb#L98)
805
+ * [is configured to timeout connection requests in 15 seconds](./spec/acceptance/rest/client_spec.rb#L102)
804
806
  * fallback hosts
805
807
  * configured
806
- * [should make connection attempts to A.ably-realtime.com, B.ably-realtime.com, C.ably-realtime.com, D.ably-realtime.com, E.ably-realtime.com](./spec/acceptance/rest/client_spec.rb#L112)
808
+ * [should make connection attempts to A.ably-realtime.com, B.ably-realtime.com, C.ably-realtime.com, D.ably-realtime.com, E.ably-realtime.com](./spec/acceptance/rest/client_spec.rb#L115)
807
809
  * when environment is NOT production
808
- * [does not retry failed requests with fallback hosts when there is a connection error](./spec/acceptance/rest/client_spec.rb#L129)
810
+ * [does not retry failed requests with fallback hosts when there is a connection error](./spec/acceptance/rest/client_spec.rb#L132)
809
811
  * when environment is production
810
812
  * and connection times out
811
- * [tries fallback hosts 3 times](./spec/acceptance/rest/client_spec.rb#L169)
813
+ * [tries fallback hosts 3 times](./spec/acceptance/rest/client_spec.rb#L172)
812
814
  * and the total request time exeeds 10 seconds
813
- * [makes no further attempts to any fallback hosts](./spec/acceptance/rest/client_spec.rb#L184)
815
+ * [makes no further attempts to any fallback hosts](./spec/acceptance/rest/client_spec.rb#L187)
814
816
  * and connection fails
815
- * [tries fallback hosts 3 times](./spec/acceptance/rest/client_spec.rb#L200)
817
+ * [tries fallback hosts 3 times](./spec/acceptance/rest/client_spec.rb#L203)
816
818
  * with a custom host
817
819
  * that does not exist
818
- * [fails immediately and raises a Faraday Error](./spec/acceptance/rest/client_spec.rb#L216)
820
+ * [fails immediately and raises a Faraday Error](./spec/acceptance/rest/client_spec.rb#L219)
819
821
  * fallback hosts
820
- * [are never used](./spec/acceptance/rest/client_spec.rb#L237)
822
+ * [are never used](./spec/acceptance/rest/client_spec.rb#L240)
821
823
  * that times out
822
- * [fails immediately and raises a Faraday Error](./spec/acceptance/rest/client_spec.rb#L252)
824
+ * [fails immediately and raises a Faraday Error](./spec/acceptance/rest/client_spec.rb#L255)
823
825
  * fallback hosts
824
- * [are never used](./spec/acceptance/rest/client_spec.rb#L265)
826
+ * [are never used](./spec/acceptance/rest/client_spec.rb#L268)
825
827
 
826
828
  ### Ably::Models::MessageEncoders
827
829
  _(see [spec/acceptance/rest/encoders_spec.rb](./spec/acceptance/rest/encoders_spec.rb))_
@@ -934,33 +936,33 @@ _(see [spec/acceptance/rest/presence_spec.rb](./spec/acceptance/rest/presence_sp
934
936
  * with time range options
935
937
  * :start
936
938
  * with milliseconds since epoch value
937
- * [uses this value in the history request](./spec/acceptance/rest/presence_spec.rb#L143)
939
+ * [uses this value in the history request](./spec/acceptance/rest/presence_spec.rb#L150)
938
940
  * with Time object value
939
- * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/presence_spec.rb#L153)
941
+ * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/presence_spec.rb#L160)
940
942
  * :end
941
943
  * with milliseconds since epoch value
942
- * [uses this value in the history request](./spec/acceptance/rest/presence_spec.rb#L143)
944
+ * [uses this value in the history request](./spec/acceptance/rest/presence_spec.rb#L150)
943
945
  * with Time object value
944
- * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/presence_spec.rb#L153)
946
+ * [converts the value to milliseconds since epoch in the hisotry request](./spec/acceptance/rest/presence_spec.rb#L160)
945
947
  * decoding
946
948
  * with encoded fixture data
947
949
  * #history
948
- * [decodes encoded and encryped presence fixture data automatically](./spec/acceptance/rest/presence_spec.rb#L173)
949
- * #get
950
950
  * [decodes encoded and encryped presence fixture data automatically](./spec/acceptance/rest/presence_spec.rb#L180)
951
+ * #get
952
+ * [decodes encoded and encryped presence fixture data automatically](./spec/acceptance/rest/presence_spec.rb#L187)
951
953
  * decoding permutations using mocked #history
952
954
  * valid decodeable content
953
955
  * #get
954
- * [automaticaly decodes presence messages](./spec/acceptance/rest/presence_spec.rb#L236)
956
+ * [automaticaly decodes presence messages](./spec/acceptance/rest/presence_spec.rb#L243)
955
957
  * #history
956
- * [automaticaly decodes presence messages](./spec/acceptance/rest/presence_spec.rb#L253)
958
+ * [automaticaly decodes presence messages](./spec/acceptance/rest/presence_spec.rb#L260)
957
959
  * invalid data
958
960
  * #get
959
- * [returns the messages still encoded](./spec/acceptance/rest/presence_spec.rb#L284)
960
- * [logs a cipher error](./spec/acceptance/rest/presence_spec.rb#L288)
961
+ * [returns the messages still encoded](./spec/acceptance/rest/presence_spec.rb#L291)
962
+ * [logs a cipher error](./spec/acceptance/rest/presence_spec.rb#L295)
961
963
  * #history
962
- * [returns the messages still encoded](./spec/acceptance/rest/presence_spec.rb#L308)
963
- * [logs a cipher error](./spec/acceptance/rest/presence_spec.rb#L312)
964
+ * [returns the messages still encoded](./spec/acceptance/rest/presence_spec.rb#L315)
965
+ * [logs a cipher error](./spec/acceptance/rest/presence_spec.rb#L319)
964
966
 
965
967
  ### Ably::Rest::Client#stats
966
968
  _(see [spec/acceptance/rest/stats_spec.rb](./spec/acceptance/rest/stats_spec.rb))_
@@ -1017,6 +1019,10 @@ _(see [spec/unit/auth_spec.rb](./spec/unit/auth_spec.rb))_
1017
1019
  * [is compatible with original encoding](./spec/unit/auth_spec.rb#L55)
1018
1020
  * as Integer
1019
1021
  * [raises an argument error](./spec/unit/auth_spec.rb#L63)
1022
+ * defaults
1023
+ * [should default TTL to 1 hour](./spec/unit/auth_spec.rb#L73)
1024
+ * [should default capability to all](./spec/unit/auth_spec.rb#L77)
1025
+ * [should only have defaults for :ttl and :capability](./spec/unit/auth_spec.rb#L81)
1020
1026
 
1021
1027
  ### Ably::Logger
1022
1028
  _(see [spec/unit/logger_spec.rb](./spec/unit/logger_spec.rb))_
@@ -1461,147 +1467,145 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
1461
1467
  * [returns a valid ErrorInfo object](./spec/unit/models/protocol_message_spec.rb#L261)
1462
1468
 
1463
1469
  ### Ably::Models::Stats
1464
- _(see [spec/unit/models/stat_spec.rb](./spec/unit/models/stat_spec.rb))_
1470
+ _(see [spec/unit/models/stats_spec.rb](./spec/unit/models/stats_spec.rb))_
1465
1471
  * #all stats
1466
- * [returns a MessageTypes object](./spec/unit/models/stat_spec.rb#L17)
1467
- * [returns value for message counts](./spec/unit/models/stat_spec.rb#L21)
1468
- * [returns value for all data transferred](./spec/unit/models/stat_spec.rb#L25)
1469
- * [returns zero for empty values](./spec/unit/models/stat_spec.rb#L29)
1470
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L33)
1472
+ * [returns a MessageTypes object](./spec/unit/models/stats_spec.rb#L17)
1473
+ * [returns value for message counts](./spec/unit/models/stats_spec.rb#L21)
1474
+ * [returns value for all data transferred](./spec/unit/models/stats_spec.rb#L25)
1475
+ * [returns zero for empty values](./spec/unit/models/stats_spec.rb#L29)
1476
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L33)
1471
1477
  * #all
1472
- * [is a MessageCount object](./spec/unit/models/stat_spec.rb#L39)
1478
+ * [is a MessageCount object](./spec/unit/models/stats_spec.rb#L39)
1473
1479
  * #presence
1474
- * [is a MessageCount object](./spec/unit/models/stat_spec.rb#L39)
1480
+ * [is a MessageCount object](./spec/unit/models/stats_spec.rb#L39)
1475
1481
  * #messages
1476
- * [is a MessageCount object](./spec/unit/models/stat_spec.rb#L39)
1482
+ * [is a MessageCount object](./spec/unit/models/stats_spec.rb#L39)
1477
1483
  * #persisted stats
1478
- * [returns a MessageTypes object](./spec/unit/models/stat_spec.rb#L17)
1479
- * [returns value for message counts](./spec/unit/models/stat_spec.rb#L21)
1480
- * [returns value for all data transferred](./spec/unit/models/stat_spec.rb#L25)
1481
- * [returns zero for empty values](./spec/unit/models/stat_spec.rb#L29)
1482
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L33)
1484
+ * [returns a MessageTypes object](./spec/unit/models/stats_spec.rb#L17)
1485
+ * [returns value for message counts](./spec/unit/models/stats_spec.rb#L21)
1486
+ * [returns value for all data transferred](./spec/unit/models/stats_spec.rb#L25)
1487
+ * [returns zero for empty values](./spec/unit/models/stats_spec.rb#L29)
1488
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L33)
1483
1489
  * #all
1484
- * [is a MessageCount object](./spec/unit/models/stat_spec.rb#L39)
1490
+ * [is a MessageCount object](./spec/unit/models/stats_spec.rb#L39)
1485
1491
  * #presence
1486
- * [is a MessageCount object](./spec/unit/models/stat_spec.rb#L39)
1492
+ * [is a MessageCount object](./spec/unit/models/stats_spec.rb#L39)
1487
1493
  * #messages
1488
- * [is a MessageCount object](./spec/unit/models/stat_spec.rb#L39)
1494
+ * [is a MessageCount object](./spec/unit/models/stats_spec.rb#L39)
1489
1495
  * #inbound stats
1490
- * [returns a MessageTraffic object](./spec/unit/models/stat_spec.rb#L59)
1491
- * [returns value for realtime message counts](./spec/unit/models/stat_spec.rb#L63)
1492
- * [returns value for all presence data](./spec/unit/models/stat_spec.rb#L67)
1493
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L71)
1496
+ * [returns a MessageTraffic object](./spec/unit/models/stats_spec.rb#L59)
1497
+ * [returns value for realtime message counts](./spec/unit/models/stats_spec.rb#L63)
1498
+ * [returns value for all presence data](./spec/unit/models/stats_spec.rb#L67)
1499
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L71)
1494
1500
  * #realtime
1495
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1501
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1496
1502
  * #rest
1497
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1503
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1498
1504
  * #webhook
1499
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1505
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1500
1506
  * #all
1501
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1507
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1502
1508
  * #outbound stats
1503
- * [returns a MessageTraffic object](./spec/unit/models/stat_spec.rb#L59)
1504
- * [returns value for realtime message counts](./spec/unit/models/stat_spec.rb#L63)
1505
- * [returns value for all presence data](./spec/unit/models/stat_spec.rb#L67)
1506
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L71)
1509
+ * [returns a MessageTraffic object](./spec/unit/models/stats_spec.rb#L59)
1510
+ * [returns value for realtime message counts](./spec/unit/models/stats_spec.rb#L63)
1511
+ * [returns value for all presence data](./spec/unit/models/stats_spec.rb#L67)
1512
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L71)
1507
1513
  * #realtime
1508
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1514
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1509
1515
  * #rest
1510
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1516
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1511
1517
  * #webhook
1512
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1518
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1513
1519
  * #all
1514
- * [is a MessageTypes object](./spec/unit/models/stat_spec.rb#L77)
1520
+ * [is a MessageTypes object](./spec/unit/models/stats_spec.rb#L77)
1515
1521
  * #connections stats
1516
- * [returns a ConnectionTypes object](./spec/unit/models/stat_spec.rb#L91)
1517
- * [returns value for tls opened counts](./spec/unit/models/stat_spec.rb#L95)
1518
- * [returns value for all peak connections](./spec/unit/models/stat_spec.rb#L99)
1519
- * [returns zero for empty values](./spec/unit/models/stat_spec.rb#L103)
1520
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L107)
1522
+ * [returns a ConnectionTypes object](./spec/unit/models/stats_spec.rb#L91)
1523
+ * [returns value for tls opened counts](./spec/unit/models/stats_spec.rb#L95)
1524
+ * [returns value for all peak connections](./spec/unit/models/stats_spec.rb#L99)
1525
+ * [returns zero for empty values](./spec/unit/models/stats_spec.rb#L103)
1526
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L107)
1521
1527
  * #tls
1522
- * [is a ResourceCount object](./spec/unit/models/stat_spec.rb#L113)
1528
+ * [is a ResourceCount object](./spec/unit/models/stats_spec.rb#L113)
1523
1529
  * #plain
1524
- * [is a ResourceCount object](./spec/unit/models/stat_spec.rb#L113)
1530
+ * [is a ResourceCount object](./spec/unit/models/stats_spec.rb#L113)
1525
1531
  * #all
1526
- * [is a ResourceCount object](./spec/unit/models/stat_spec.rb#L113)
1532
+ * [is a ResourceCount object](./spec/unit/models/stats_spec.rb#L113)
1527
1533
  * #channels stats
1528
- * [returns a ResourceCount object](./spec/unit/models/stat_spec.rb#L126)
1529
- * [returns value for opened counts](./spec/unit/models/stat_spec.rb#L130)
1530
- * [returns value for peak channels](./spec/unit/models/stat_spec.rb#L134)
1531
- * [returns zero for empty values](./spec/unit/models/stat_spec.rb#L138)
1532
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L142)
1534
+ * [returns a ResourceCount object](./spec/unit/models/stats_spec.rb#L126)
1535
+ * [returns value for opened counts](./spec/unit/models/stats_spec.rb#L130)
1536
+ * [returns value for peak channels](./spec/unit/models/stats_spec.rb#L134)
1537
+ * [returns zero for empty values](./spec/unit/models/stats_spec.rb#L138)
1538
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L142)
1533
1539
  * #opened
1534
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L148)
1540
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L148)
1535
1541
  * #peak
1536
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L148)
1542
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L148)
1537
1543
  * #mean
1538
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L148)
1544
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L148)
1539
1545
  * #min
1540
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L148)
1546
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L148)
1541
1547
  * #refused
1542
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L148)
1548
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L148)
1543
1549
  * #api_requests stats
1544
- * [returns a RequestCount object](./spec/unit/models/stat_spec.rb#L164)
1545
- * [returns value for succeeded](./spec/unit/models/stat_spec.rb#L168)
1546
- * [returns value for failed](./spec/unit/models/stat_spec.rb#L172)
1547
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L176)
1550
+ * [returns a RequestCount object](./spec/unit/models/stats_spec.rb#L164)
1551
+ * [returns value for succeeded](./spec/unit/models/stats_spec.rb#L168)
1552
+ * [returns value for failed](./spec/unit/models/stats_spec.rb#L172)
1553
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L176)
1548
1554
  * #succeeded
1549
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L182)
1555
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L182)
1550
1556
  * #failed
1551
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L182)
1557
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L182)
1552
1558
  * #refused
1553
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L182)
1559
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L182)
1554
1560
  * #token_requests stats
1555
- * [returns a RequestCount object](./spec/unit/models/stat_spec.rb#L164)
1556
- * [returns value for succeeded](./spec/unit/models/stat_spec.rb#L168)
1557
- * [returns value for failed](./spec/unit/models/stat_spec.rb#L172)
1558
- * [raises an exception for unknown attributes](./spec/unit/models/stat_spec.rb#L176)
1561
+ * [returns a RequestCount object](./spec/unit/models/stats_spec.rb#L164)
1562
+ * [returns value for succeeded](./spec/unit/models/stats_spec.rb#L168)
1563
+ * [returns value for failed](./spec/unit/models/stats_spec.rb#L172)
1564
+ * [raises an exception for unknown attributes](./spec/unit/models/stats_spec.rb#L176)
1559
1565
  * #succeeded
1560
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L182)
1566
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L182)
1561
1567
  * #failed
1562
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L182)
1568
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L182)
1563
1569
  * #refused
1564
- * [is a Integer object](./spec/unit/models/stat_spec.rb#L182)
1570
+ * [is a Integer object](./spec/unit/models/stats_spec.rb#L182)
1565
1571
  * #interval_granularity
1566
- * [returns the granularity of the interval_id](./spec/unit/models/stat_spec.rb#L193)
1572
+ * [returns the granularity of the interval_id](./spec/unit/models/stats_spec.rb#L193)
1567
1573
  * #interval_time
1568
- * [returns a Time object representing the start of the interval](./spec/unit/models/stat_spec.rb#L201)
1574
+ * [returns a Time object representing the start of the interval](./spec/unit/models/stats_spec.rb#L201)
1569
1575
  * class methods
1570
1576
  * #to_interval_id
1571
1577
  * when time zone of time argument is UTC
1572
- * [converts time 2014-02-03:05:06 with granularity :month into 2014-02](./spec/unit/models/stat_spec.rb#L209)
1573
- * [converts time 2014-02-03:05:06 with granularity :day into 2014-02-03](./spec/unit/models/stat_spec.rb#L213)
1574
- * [converts time 2014-02-03:05:06 with granularity :hour into 2014-02-03:05](./spec/unit/models/stat_spec.rb#L217)
1575
- * [converts time 2014-02-03:05:06 with granularity :minute into 2014-02-03:05:06](./spec/unit/models/stat_spec.rb#L221)
1576
- * [fails with invalid granularity](./spec/unit/models/stat_spec.rb#L225)
1577
- * [fails with invalid time](./spec/unit/models/stat_spec.rb#L229)
1578
+ * [converts time 2014-02-03:05:06 with granularity :month into 2014-02](./spec/unit/models/stats_spec.rb#L209)
1579
+ * [converts time 2014-02-03:05:06 with granularity :day into 2014-02-03](./spec/unit/models/stats_spec.rb#L213)
1580
+ * [converts time 2014-02-03:05:06 with granularity :hour into 2014-02-03:05](./spec/unit/models/stats_spec.rb#L217)
1581
+ * [converts time 2014-02-03:05:06 with granularity :minute into 2014-02-03:05:06](./spec/unit/models/stats_spec.rb#L221)
1582
+ * [fails with invalid granularity](./spec/unit/models/stats_spec.rb#L225)
1583
+ * [fails with invalid time](./spec/unit/models/stats_spec.rb#L229)
1578
1584
  * when time zone of time argument is +02:00
1579
- * [converts time 2014-02-03:06 with granularity :hour into 2014-02-03:04 at UTC +00:00](./spec/unit/models/stat_spec.rb#L235)
1585
+ * [converts time 2014-02-03:06 with granularity :hour into 2014-02-03:04 at UTC +00:00](./spec/unit/models/stats_spec.rb#L235)
1580
1586
  * #from_interval_id
1581
- * [converts a month interval_id 2014-02 into a Time object in UTC 0](./spec/unit/models/stat_spec.rb#L242)
1582
- * [converts a day interval_id 2014-02-03 into a Time object in UTC 0](./spec/unit/models/stat_spec.rb#L247)
1583
- * [converts an hour interval_id 2014-02-03:05 into a Time object in UTC 0](./spec/unit/models/stat_spec.rb#L252)
1584
- * [converts a minute interval_id 2014-02-03:05:06 into a Time object in UTC 0](./spec/unit/models/stat_spec.rb#L257)
1585
- * [fails with an invalid interval_id 14-20](./spec/unit/models/stat_spec.rb#L262)
1587
+ * [converts a month interval_id 2014-02 into a Time object in UTC 0](./spec/unit/models/stats_spec.rb#L242)
1588
+ * [converts a day interval_id 2014-02-03 into a Time object in UTC 0](./spec/unit/models/stats_spec.rb#L247)
1589
+ * [converts an hour interval_id 2014-02-03:05 into a Time object in UTC 0](./spec/unit/models/stats_spec.rb#L252)
1590
+ * [converts a minute interval_id 2014-02-03:05:06 into a Time object in UTC 0](./spec/unit/models/stats_spec.rb#L257)
1591
+ * [fails with an invalid interval_id 14-20](./spec/unit/models/stats_spec.rb#L262)
1586
1592
  * #granularity_from_interval_id
1587
- * [returns a :month interval_id for 2014-02](./spec/unit/models/stat_spec.rb#L268)
1588
- * [returns a :day interval_id for 2014-02-03](./spec/unit/models/stat_spec.rb#L272)
1589
- * [returns a :hour interval_id for 2014-02-03:05](./spec/unit/models/stat_spec.rb#L276)
1590
- * [returns a :minute interval_id for 2014-02-03:05:06](./spec/unit/models/stat_spec.rb#L280)
1591
- * [fails with an invalid interval_id 14-20](./spec/unit/models/stat_spec.rb#L284)
1593
+ * [returns a :month interval_id for 2014-02](./spec/unit/models/stats_spec.rb#L268)
1594
+ * [returns a :day interval_id for 2014-02-03](./spec/unit/models/stats_spec.rb#L272)
1595
+ * [returns a :hour interval_id for 2014-02-03:05](./spec/unit/models/stats_spec.rb#L276)
1596
+ * [returns a :minute interval_id for 2014-02-03:05:06](./spec/unit/models/stats_spec.rb#L280)
1597
+ * [fails with an invalid interval_id 14-20](./spec/unit/models/stats_spec.rb#L284)
1592
1598
 
1593
- ### Ably::Models::Token
1594
- _(see [spec/unit/models/token_spec.rb](./spec/unit/models/token_spec.rb))_
1599
+ ### Ably::Models::TokenDetails
1600
+ _(see [spec/unit/models/token_details_spec.rb](./spec/unit/models/token_details_spec.rb))_
1595
1601
  * behaves like a model
1596
1602
  * attributes
1597
- * #id
1598
- * [retrieves attribute :id](./spec/shared/model_behaviour.rb#L15)
1599
- * #capability
1600
- * [retrieves attribute :capability](./spec/shared/model_behaviour.rb#L15)
1603
+ * #token
1604
+ * [retrieves attribute :token](./spec/shared/model_behaviour.rb#L15)
1605
+ * #key_name
1606
+ * [retrieves attribute :key_name](./spec/shared/model_behaviour.rb#L15)
1601
1607
  * #client_id
1602
1608
  * [retrieves attribute :client_id](./spec/shared/model_behaviour.rb#L15)
1603
- * #nonce
1604
- * [retrieves attribute :nonce](./spec/shared/model_behaviour.rb#L15)
1605
1609
  * #==
1606
1610
  * [is true when attributes are the same](./spec/shared/model_behaviour.rb#L41)
1607
1611
  * [is false when attributes are not the same](./spec/shared/model_behaviour.rb#L46)
@@ -1609,26 +1613,69 @@ _(see [spec/unit/models/token_spec.rb](./spec/unit/models/token_spec.rb))_
1609
1613
  * is immutable
1610
1614
  * [prevents changes](./spec/shared/model_behaviour.rb#L76)
1611
1615
  * [dups options](./spec/shared/model_behaviour.rb#L80)
1612
- * defaults
1613
- * [should default TTL to 1 hour](./spec/unit/models/token_spec.rb#L14)
1614
- * [should default capability to all](./spec/unit/models/token_spec.rb#L18)
1615
- * [should only have defaults for :ttl and :capability](./spec/unit/models/token_spec.rb#L22)
1616
1616
  * attributes
1617
- * #key_id
1618
- * [retrieves attribute :key](./spec/unit/models/token_spec.rb#L32)
1619
- * #issued_at
1620
- * [retrieves attribute :issued_at as Time](./spec/unit/models/token_spec.rb#L42)
1621
- * #expires_at
1622
- * [retrieves attribute :expires as Time](./spec/unit/models/token_spec.rb#L42)
1617
+ * #capability
1618
+ * [retrieves attribute :capability as parsed JSON](./spec/unit/models/token_details_spec.rb#L21)
1619
+ * #issued with :issued option as milliseconds in constructor
1620
+ * [retrieves attribute :issued as Time](./spec/unit/models/token_details_spec.rb#L31)
1621
+ * #issued with :issued option as a Time in constructor
1622
+ * [retrieves attribute :issued as Time](./spec/unit/models/token_details_spec.rb#L40)
1623
+ * #issued when converted to JSON
1624
+ * [is in milliseconds](./spec/unit/models/token_details_spec.rb#L49)
1625
+ * #expires with :expires option as milliseconds in constructor
1626
+ * [retrieves attribute :expires as Time](./spec/unit/models/token_details_spec.rb#L31)
1627
+ * #expires with :expires option as a Time in constructor
1628
+ * [retrieves attribute :expires as Time](./spec/unit/models/token_details_spec.rb#L40)
1629
+ * #expires when converted to JSON
1630
+ * [is in milliseconds](./spec/unit/models/token_details_spec.rb#L49)
1623
1631
  * #expired?
1624
1632
  * once grace period buffer has passed
1625
- * [is true](./spec/unit/models/token_spec.rb#L55)
1633
+ * [is true](./spec/unit/models/token_details_spec.rb#L61)
1626
1634
  * within grace period buffer
1627
- * [is false](./spec/unit/models/token_spec.rb#L63)
1635
+ * [is false](./spec/unit/models/token_details_spec.rb#L69)
1636
+ * ==
1637
+ * [is true when attributes are the same](./spec/unit/models/token_details_spec.rb#L79)
1638
+ * [is false when attributes are not the same](./spec/unit/models/token_details_spec.rb#L84)
1639
+ * [is false when class type differs](./spec/unit/models/token_details_spec.rb#L88)
1640
+
1641
+ ### Ably::Models::TokenRequest
1642
+ _(see [spec/unit/models/token_request_spec.rb](./spec/unit/models/token_request_spec.rb))_
1643
+ * behaves like a model
1644
+ * attributes
1645
+ * #key_name
1646
+ * [retrieves attribute :key_name](./spec/shared/model_behaviour.rb#L15)
1647
+ * #client_id
1648
+ * [retrieves attribute :client_id](./spec/shared/model_behaviour.rb#L15)
1649
+ * #nonce
1650
+ * [retrieves attribute :nonce](./spec/shared/model_behaviour.rb#L15)
1651
+ * #mac
1652
+ * [retrieves attribute :mac](./spec/shared/model_behaviour.rb#L15)
1653
+ * #==
1654
+ * [is true when attributes are the same](./spec/shared/model_behaviour.rb#L41)
1655
+ * [is false when attributes are not the same](./spec/shared/model_behaviour.rb#L46)
1656
+ * [is false when class type differs](./spec/shared/model_behaviour.rb#L50)
1657
+ * is immutable
1658
+ * [prevents changes](./spec/shared/model_behaviour.rb#L76)
1659
+ * [dups options](./spec/shared/model_behaviour.rb#L80)
1660
+ * attributes
1661
+ * #capability
1662
+ * [retrieves attribute :capability as parsed JSON](./spec/unit/models/token_request_spec.rb#L18)
1663
+ * #timestamp
1664
+ * with :timestamp option as milliseconds in constructor
1665
+ * [retrieves attribute :timestamp as Time](./spec/unit/models/token_request_spec.rb#L29)
1666
+ * with :timestamp option as Time in constructor
1667
+ * [retrieves attribute :timestamp as Time](./spec/unit/models/token_request_spec.rb#L38)
1668
+ * when converted to JSON
1669
+ * [is in milliseconds since epoch](./spec/unit/models/token_request_spec.rb#L47)
1670
+ * #ttl
1671
+ * with :ttl option as milliseconds in constructor
1672
+ * [retrieves attribute :ttl as seconds](./spec/unit/models/token_request_spec.rb#L59)
1673
+ * when converted to JSON
1674
+ * [is in milliseconds since epoch](./spec/unit/models/token_request_spec.rb#L68)
1628
1675
  * ==
1629
- * [is true when attributes are the same](./spec/unit/models/token_spec.rb#L73)
1630
- * [is false when attributes are not the same](./spec/unit/models/token_spec.rb#L78)
1631
- * [is false when class type differs](./spec/unit/models/token_spec.rb#L82)
1676
+ * [is true when attributes are the same](./spec/unit/models/token_request_spec.rb#L78)
1677
+ * [is false when attributes are not the same](./spec/unit/models/token_request_spec.rb#L83)
1678
+ * [is false when class type differs](./spec/unit/models/token_request_spec.rb#L87)
1632
1679
 
1633
1680
  ### Ably::Modules::EventEmitter
1634
1681
  _(see [spec/unit/modules/event_emitter_spec.rb](./spec/unit/modules/event_emitter_spec.rb))_
@@ -1751,7 +1798,7 @@ _(see [spec/unit/realtime/client_spec.rb](./spec/unit/realtime/client_spec.rb))_
1751
1798
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L44)
1752
1799
  * key: "invalid:asdad"
1753
1800
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L52)
1754
- * key and key_id
1801
+ * key and key_name
1755
1802
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L60)
1756
1803
  * key and key_secret
1757
1804
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L68)
@@ -1760,40 +1807,37 @@ _(see [spec/unit/realtime/client_spec.rb](./spec/unit/realtime/client_spec.rb))_
1760
1807
  * with valid arguments
1761
1808
  * key only
1762
1809
  * [connects to the Ably service](./spec/shared/client_initializer_behaviour.rb#L87)
1763
- * with legacy :api_key only
1764
- * [connects to the Ably service](./spec/shared/client_initializer_behaviour.rb#L94)
1765
- * [sets the Auth#key](./spec/shared/client_initializer_behaviour.rb#L98)
1766
- * key_id and key_secret
1767
- * [constructs an key](./spec/shared/client_initializer_behaviour.rb#L106)
1768
1810
  * with a string key instead of options hash
1769
- * [sets the key](./spec/shared/client_initializer_behaviour.rb#L114)
1770
- * [sets the key_id](./spec/shared/client_initializer_behaviour.rb#L118)
1771
- * [sets the key_secret](./spec/shared/client_initializer_behaviour.rb#L122)
1811
+ * [sets the key](./spec/shared/client_initializer_behaviour.rb#L103)
1812
+ * [sets the key_name](./spec/shared/client_initializer_behaviour.rb#L107)
1813
+ * [sets the key_secret](./spec/shared/client_initializer_behaviour.rb#L111)
1772
1814
  * with a string token key instead of options hash
1773
- * [sets the token_id](./spec/shared/client_initializer_behaviour.rb#L130)
1815
+ * [sets the token](./spec/shared/client_initializer_behaviour.rb#L119)
1774
1816
  * with token
1775
- * [sets the token_id](./spec/shared/client_initializer_behaviour.rb#L138)
1817
+ * [sets the token](./spec/shared/client_initializer_behaviour.rb#L127)
1818
+ * with token_details
1819
+ * [sets the token](./spec/shared/client_initializer_behaviour.rb#L135)
1776
1820
  * endpoint
1777
- * [defaults to production](./spec/shared/client_initializer_behaviour.rb#L144)
1821
+ * [defaults to production](./spec/shared/client_initializer_behaviour.rb#L141)
1778
1822
  * with environment option
1779
- * [uses an alternate endpoint](./spec/shared/client_initializer_behaviour.rb#L151)
1823
+ * [uses an alternate endpoint](./spec/shared/client_initializer_behaviour.rb#L148)
1780
1824
  * tls
1781
- * [defaults to TLS](./spec/shared/client_initializer_behaviour.rb#L170)
1825
+ * [defaults to TLS](./spec/shared/client_initializer_behaviour.rb#L167)
1782
1826
  * set to false
1783
- * [uses plain text](./spec/shared/client_initializer_behaviour.rb#L161)
1784
- * [uses HTTP](./spec/shared/client_initializer_behaviour.rb#L165)
1827
+ * [uses plain text](./spec/shared/client_initializer_behaviour.rb#L158)
1828
+ * [uses HTTP](./spec/shared/client_initializer_behaviour.rb#L162)
1785
1829
  * logger
1786
1830
  * default
1787
- * [uses Ruby Logger](./spec/shared/client_initializer_behaviour.rb#L177)
1788
- * [specifies Logger::ERROR log level](./spec/shared/client_initializer_behaviour.rb#L181)
1831
+ * [uses Ruby Logger](./spec/shared/client_initializer_behaviour.rb#L174)
1832
+ * [specifies Logger::ERROR log level](./spec/shared/client_initializer_behaviour.rb#L178)
1789
1833
  * with log_level :none
1790
- * [silences all logging with a NilLogger](./spec/shared/client_initializer_behaviour.rb#L189)
1834
+ * [silences all logging with a NilLogger](./spec/shared/client_initializer_behaviour.rb#L186)
1791
1835
  * with custom logger and log_level
1792
- * [uses the custom logger](./spec/shared/client_initializer_behaviour.rb#L207)
1793
- * [sets the custom log level](./spec/shared/client_initializer_behaviour.rb#L211)
1836
+ * [uses the custom logger](./spec/shared/client_initializer_behaviour.rb#L204)
1837
+ * [sets the custom log level](./spec/shared/client_initializer_behaviour.rb#L208)
1794
1838
  * delegators
1795
- * [delegates :client_id to .auth](./spec/shared/client_initializer_behaviour.rb#L221)
1796
- * [delegates :auth_options to .auth](./spec/shared/client_initializer_behaviour.rb#L226)
1839
+ * [delegates :client_id to .auth](./spec/shared/client_initializer_behaviour.rb#L218)
1840
+ * [delegates :auth_options to .auth](./spec/shared/client_initializer_behaviour.rb#L223)
1797
1841
  * delegation to the REST Client
1798
1842
  * [passes on the options to the initializer](./spec/unit/realtime/client_spec.rb#L15)
1799
1843
  * for attribute
@@ -1931,7 +1975,7 @@ _(see [spec/unit/rest/client_spec.rb](./spec/unit/rest/client_spec.rb))_
1931
1975
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L44)
1932
1976
  * key: "invalid:asdad"
1933
1977
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L52)
1934
- * key and key_id
1978
+ * key and key_name
1935
1979
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L60)
1936
1980
  * key and key_secret
1937
1981
  * [raises an exception](./spec/shared/client_initializer_behaviour.rb#L68)
@@ -1940,40 +1984,37 @@ _(see [spec/unit/rest/client_spec.rb](./spec/unit/rest/client_spec.rb))_
1940
1984
  * with valid arguments
1941
1985
  * key only
1942
1986
  * [connects to the Ably service](./spec/shared/client_initializer_behaviour.rb#L87)
1943
- * with legacy :api_key only
1944
- * [connects to the Ably service](./spec/shared/client_initializer_behaviour.rb#L94)
1945
- * [sets the Auth#key](./spec/shared/client_initializer_behaviour.rb#L98)
1946
- * key_id and key_secret
1947
- * [constructs an key](./spec/shared/client_initializer_behaviour.rb#L106)
1948
1987
  * with a string key instead of options hash
1949
- * [sets the key](./spec/shared/client_initializer_behaviour.rb#L114)
1950
- * [sets the key_id](./spec/shared/client_initializer_behaviour.rb#L118)
1951
- * [sets the key_secret](./spec/shared/client_initializer_behaviour.rb#L122)
1988
+ * [sets the key](./spec/shared/client_initializer_behaviour.rb#L103)
1989
+ * [sets the key_name](./spec/shared/client_initializer_behaviour.rb#L107)
1990
+ * [sets the key_secret](./spec/shared/client_initializer_behaviour.rb#L111)
1952
1991
  * with a string token key instead of options hash
1953
- * [sets the token_id](./spec/shared/client_initializer_behaviour.rb#L130)
1992
+ * [sets the token](./spec/shared/client_initializer_behaviour.rb#L119)
1954
1993
  * with token
1955
- * [sets the token_id](./spec/shared/client_initializer_behaviour.rb#L138)
1994
+ * [sets the token](./spec/shared/client_initializer_behaviour.rb#L127)
1995
+ * with token_details
1996
+ * [sets the token](./spec/shared/client_initializer_behaviour.rb#L135)
1956
1997
  * endpoint
1957
- * [defaults to production](./spec/shared/client_initializer_behaviour.rb#L144)
1998
+ * [defaults to production](./spec/shared/client_initializer_behaviour.rb#L141)
1958
1999
  * with environment option
1959
- * [uses an alternate endpoint](./spec/shared/client_initializer_behaviour.rb#L151)
2000
+ * [uses an alternate endpoint](./spec/shared/client_initializer_behaviour.rb#L148)
1960
2001
  * tls
1961
- * [defaults to TLS](./spec/shared/client_initializer_behaviour.rb#L170)
2002
+ * [defaults to TLS](./spec/shared/client_initializer_behaviour.rb#L167)
1962
2003
  * set to false
1963
- * [uses plain text](./spec/shared/client_initializer_behaviour.rb#L161)
1964
- * [uses HTTP](./spec/shared/client_initializer_behaviour.rb#L165)
2004
+ * [uses plain text](./spec/shared/client_initializer_behaviour.rb#L158)
2005
+ * [uses HTTP](./spec/shared/client_initializer_behaviour.rb#L162)
1965
2006
  * logger
1966
2007
  * default
1967
- * [uses Ruby Logger](./spec/shared/client_initializer_behaviour.rb#L177)
1968
- * [specifies Logger::ERROR log level](./spec/shared/client_initializer_behaviour.rb#L181)
2008
+ * [uses Ruby Logger](./spec/shared/client_initializer_behaviour.rb#L174)
2009
+ * [specifies Logger::ERROR log level](./spec/shared/client_initializer_behaviour.rb#L178)
1969
2010
  * with log_level :none
1970
- * [silences all logging with a NilLogger](./spec/shared/client_initializer_behaviour.rb#L189)
2011
+ * [silences all logging with a NilLogger](./spec/shared/client_initializer_behaviour.rb#L186)
1971
2012
  * with custom logger and log_level
1972
- * [uses the custom logger](./spec/shared/client_initializer_behaviour.rb#L207)
1973
- * [sets the custom log level](./spec/shared/client_initializer_behaviour.rb#L211)
2013
+ * [uses the custom logger](./spec/shared/client_initializer_behaviour.rb#L204)
2014
+ * [sets the custom log level](./spec/shared/client_initializer_behaviour.rb#L208)
1974
2015
  * delegators
1975
- * [delegates :client_id to .auth](./spec/shared/client_initializer_behaviour.rb#L221)
1976
- * [delegates :auth_options to .auth](./spec/shared/client_initializer_behaviour.rb#L226)
2016
+ * [delegates :client_id to .auth](./spec/shared/client_initializer_behaviour.rb#L218)
2017
+ * [delegates :auth_options to .auth](./spec/shared/client_initializer_behaviour.rb#L223)
1977
2018
  * initializer options
1978
2019
  * TLS
1979
2020
  * disabled
@@ -1985,7 +2026,7 @@ _(see [spec/unit/rest/client_spec.rb](./spec/unit/rest/client_spec.rb))_
1985
2026
  * without an key
1986
2027
  * [fails as an key is required if not using token auth](./spec/unit/rest/client_spec.rb#L36)
1987
2028
  * set to true
1988
- * without an key or token_id
2029
+ * without an key or token
1989
2030
  * [fails as an key is required to issue tokens](./spec/unit/rest/client_spec.rb#L46)
1990
2031
 
1991
2032
  ### Ably::Rest
@@ -2027,6 +2068,6 @@ _(see [spec/unit/util/pub_sub_spec.rb](./spec/unit/util/pub_sub_spec.rb))_
2027
2068
 
2028
2069
  ## Test summary
2029
2070
 
2030
- * Passing tests: 1011
2071
+ * Passing tests: 1028
2031
2072
  * Pending tests: 7
2032
2073
  * Failing tests: 0