Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
78905ad
Add docs workflow to ably-ruby
Sep 2, 2022
3739fcd
Execute yard run command within bundle exec
Sep 2, 2022
4a0ed71
Fix lib/ably/util/crypto.rb descriptions
Sep 12, 2022
2a41786
Fix lib/ably/rest/push/device_registrations.rb descriptions
Sep 12, 2022
085a197
Fix lib/ably/rest/push/admin.rb descriptions
Sep 12, 2022
b33fc8b
Fix lib/ably/rest/push.rb descriptions
Sep 12, 2022
5167490
Fix lib/ably/rest/presence.rb descriptions
Sep 12, 2022
fa9bdac
Fix lib/ably/rest/client.rb descriptions
Sep 12, 2022
7e5f648
Fix lib/ably/rest/channels.rb descriptions
Sep 12, 2022
239716d
Fix lib/ably/rest/channel/push_channel.rb
Sep 12, 2022
5d40aa8
Fix lib/ably/rest/channel.rb descriptions
Sep 12, 2022
a89e6a2
Fix lib/ably/realtime/push/admin.rb descriptions
Sep 12, 2022
90af70d
Fix lib/ably/realtime/push.rb descriptions
Sep 12, 2022
c838162
Fix lib/ably/realtime/presence.rb descriptions
Sep 12, 2022
e750fe1
Fix lib/ably/realtime/connection/websocket_transport.rb descriptions
Sep 12, 2022
93193d7
Fix lib/ably/realtime/connection/connection_manager.rb descriptions
Sep 12, 2022
9d7cd64
Fix lib/ably/realtime/connection.rb descriptions
Sep 12, 2022
a25e6c5
Fix lib/ably/realtime/client.rb descriptions
Sep 12, 2022
2914fb8
Fix lib/ably/realtime/channels.rb descriptions
Sep 12, 2022
27b6a65
Fix lib/ably/realtime/channel/push_channel.rb descriptions
Sep 12, 2022
f550994
Fix lib/ably/realtime/channel/publisher.rb descriptions
Sep 12, 2022
fe6941d
Fix lib/ably/realtime/channel/channel_properties.rb descriptions
Sep 12, 2022
601d03b
Fix lib/ably/realtime/channel.rb descriptions
Sep 12, 2022
1f42cc0
Fix lib/ably/modules/state_machine.rb descriptions
Sep 12, 2022
9cb72e8
Fix lib/ably/modules/state_emitter.rb descriptions
Sep 12, 2022
85c486b
Fix lib/ably/modules/model_common.rb descriptions
Sep 12, 2022
79d6c03
Fix lib/ably/modules/event_emitter.rb descriptions
Sep 12, 2022
ab324bc
Fix lib/ably/modules/enum.rb descriptions
Sep 12, 2022
174a525
Fix lib/ably/modules/async_wrapper.rb descriptions
Sep 12, 2022
b523cfc
Fix lib/ably/models/token_request.rb descriptions
Sep 12, 2022
3e07863
Fix lib/ably/models/token_details.rb descriptions
Sep 12, 2022
016095d
Fix lib/ably/models/stats_types.rb descriptions
Sep 12, 2022
ef3ebb2
Fix lib/ably/models/stats.rb descriptions
Sep 12, 2022
89aed93
Fix lib/ably/models/push_channel_subscription.rb descriptions
Sep 12, 2022
bf3dc1f
Fix lib/ably/models/presence_message.rb descriptions
Sep 12, 2022
04a92cc
Fix lib/ably/models/paginated_result.rb descriptions
Sep 12, 2022
76de89e
Fix lib/ably/models/message_encoders/base.rb descriptions
Sep 12, 2022
936ba8a
Fix lib/ably/models/message.rb descriptions
Sep 12, 2022
3f0ec5f
Fix lib/ably/models/idiomatic_ruby_wrapper.rb descriptions
Sep 12, 2022
d90d5a2
Fix lib/ably/models/http_paginated_response.rb descriptions
Sep 12, 2022
d15a7a8
Fix lib/ably/models/error_info.rb descriptions
Sep 12, 2022
73e2152
Fix lib/ably/models/device_push_details.rb descriptions
Sep 12, 2022
9eacd63
Fix lib/ably/models/device_details.rb descriptions
Sep 12, 2022
2bd0082
Fix lib/ably/models/delta_extras.rb descriptions
Sep 12, 2022
aeb5284
Fix lib/ably/models/connection_state_change.rb descriptions
Sep 12, 2022
f8c7b85
Fix lib/ably/models/connection_details.rb descriptions
Sep 12, 2022
373bab7
Fix lib/ably/models/cipher_params.rb descriptions
Sep 12, 2022
1da0f22
Fix lib/ably/models/channel_status.rb descriptions
Sep 12, 2022
2099c95
Fix lib/ably/models/channel_state_change.rb descriptions
Sep 12, 2022
e51e033
Fix lib/ably/models/channel_options.rb descriptions
Sep 12, 2022
c8b8fe6
Fix lib/ably/models/channel_occupancy.rb descriptions
Sep 12, 2022
3a73825
Fix lib/ably/models/channel_metrics.rb descriptions
Sep 12, 2022
c49e0e7
Fix lib/ably/models/channel_details.rb descriptions
Sep 12, 2022
af0489f
Fix lib/ably/models/auth_details.rb descriptions
Sep 12, 2022
887f442
Fix lib/ably/auth.rb descriptions
Sep 12, 2022
0641332
Fix README.md
Sep 12, 2022
ad530ba
Fix lib/ably/models/device_push_details.rb
Sep 12, 2022
add5041
Fix lib/ably/models/presence_message.rb
Sep 12, 2022
958cc0c
Revert "Fix README.md"
Sep 19, 2022
9ef1478
Add INTRO.md
Sep 19, 2022
929d776
Set --readme option to yard
Sep 19, 2022
d240e61
Add newline
Sep 19, 2022
acd5b50
Fix lib/ably/models/idiomatic_ruby_wrapper.rb
Sep 19, 2022
bfb059a
Fix lib/ably/models/paginated_result.rb
Sep 19, 2022
6917596
Fix lib/ably/models/token_request.rb
Sep 19, 2022
af58660
Fix lib/ably/realtime/presence.rb
Sep 19, 2022
e5bc1a3
Fixe lib/ably/rest/client.rb
Sep 19, 2022
1157a2d
Fix lib/ably/rest/client.rb
Sep 19, 2022
d09a686
Fix lib/ably/rest/client.rb
Sep 19, 2022
fb25a5f
Add --tag "spec:Specification" to yard
Sep 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
deployments: write
id-token: write
steps:
- uses: actions/checkout@v2

- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Build Documentation
run: |
bundle exec yard --readme INTRO.md --tag "spec:Specification"
ls -al doc/
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-2
role-to-assume: arn:aws:iam::${{ secrets.ABLY_AWS_ACCOUNT_ID_SDK }}:role/ably-sdk-builds-ably-ruby
role-session-name: "${{ github.run_id }}-${{ github.run_number }}"

- name: Upload Documentation
uses: ably/sdk-upload-action@v1
with:
sourcePath: doc/
githubToken: ${{ secrets.GITHUB_TOKEN }}
artifactName: docs
14 changes: 14 additions & 0 deletions INTRO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ably `Ruby` Client Library SDK API Reference

The `Ruby` Client Library SDK supports a realtime and a REST interface.

The realtime interface enables a client to maintain a persistent connection to Ably and publish, subscribe and be present on channels.
The REST interface is stateless and typically implemented server-side. It is used to make requests such as retrieving statistics,
token authentication and publishing to a channel.

**Note**: The `Ruby` Client Library SDK implements the realtime and REST interfaces as two separate libraries.

The `Ruby` API references are generated from the [Ably `Ruby` Client Library SDK source code](https://github.com/ably/ably-ruby)
using [`yard`](https://yardoc.org/). View the [Ably docs](http://ably.com/docs/) for conceptual information on using Ably
and for client library API references split between the [realtime](http://ably.com/docs/api/realtime-sdk)
and [REST](http://ably.com/docs/api/rest-sdk) interfaces.
49 changes: 26 additions & 23 deletions lib/ably/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,7 @@
require 'ably/rest/middleware/external_exceptions'

module Ably
# Auth is responsible for authentication with {https://www.ably.com Ably} using basic or token authentication
#
# Find out more about Ably authentication at: https://www.ably.com/docs/general/authentication/
#
# @!attribute [r] client_id
# @return [String] The provided client ID, used for identifying this client for presence purposes
# @!attribute [r] current_token_details
# @return [Ably::Models::TokenDetails] Current {Ably::Models::TokenDetails} issued by this library or one of the provided callbacks used to authenticate requests
# @!attribute [r] key
# @return [String] Complete API key containing both the key name and key secret, if present
# @!attribute [r] key_name
# @return [String] Key name (public part of the API key), if present
# @!attribute [r] key_secret
# @return [String] Key secret (private secure part of the API key), if present
# @!attribute [r] options
# @return [Hash] Default {Ably::Auth} options configured for this client
# @!attribute [r] token_params
# @return [Hash] Default token params used for token requests, see {#request_token}
# Creates Ably {Ably::Models::TokenRequest} objects and obtains Ably Tokens from Ably to subsequently issue to less trusted clients.
#
class Auth
include Ably::Modules::Conversions
Expand Down Expand Up @@ -124,9 +107,13 @@ def initialize(client, token_params, auth_options)
@token_params.freeze
end

# Ensures valid auth credentials are present for the library instance. This may rely on an already-known and valid token, and will obtain a new token if necessary.
# Instructs the library to get a new token immediately. When using the realtime client, it upgrades the current
# realtime connection to use the new token, or if not connected, initiates a connection to Ably, once the new token
# has been obtained. Also stores any `token_params` and `auth_options` passed
# in as the new defaults, to be used for all subsequent implicit or explicit token requests. Any `token_params`
# and `auth_options` objects passed in entirely replace, as opposed to being merged with, the current client library saved values.
#
# In the event that a new token request is made, the provided options are used.
# @spec RSA10
#
# @param [Hash, nil] token_params the token params used for future token requests. When nil, previously configured token params are used
# @param [Hash, nil] auth_options the authentication options used for future token requests. When nil, previously configure authentication options are used
Expand Down Expand Up @@ -205,7 +192,13 @@ def authorise(*args, &block)
authorize(*args, &block)
end

# Request a {Ably::Models::TokenDetails} which can be used to make authenticated token based requests
# Calls the requestToken REST API endpoint to obtain an Ably Token according to the specified `token_params` and `auth_options`.
# Both `token_params` and `auth_options` are optional. When omitted or null, the default token parameters and authentication
# options for the client library are used, as specified in the `client_options` when the client library was instantiated,
# or later updated with an explicit authorize request. Values passed in are used instead of, rather than being merged with, the default values.
# To understand why an Ably {Ably::Models::TokenRequest} may be issued to clients in favor of a token, see Token Authentication explained.
#
# @spec RSA8e
#
# @param [Hash] auth_options (see #create_token_request)
# @option auth_options [String] :auth_url a URL to be used to GET or POST a set of token request params, to obtain a signed token request
Expand All @@ -217,7 +210,7 @@ def authorise(*args, &block)
# @param [Hash] token_params (see #create_token_request)
# @option (see #create_token_request)
#
# @return [Ably::Models::TokenDetails]
# @return [Ably::Models::TokenDetails] A {Ably::Models::TokenDetails} object. RSA16
#
# @example
# # simple token request using basic auth
Expand Down Expand Up @@ -273,7 +266,17 @@ def request_token(token_params = {}, auth_options = {})
send_token_request(token_request)
end

# Creates and signs a token request that can then subsequently be used by any client to request a token
# Creates and signs an {Ably::Models::TokenRequest} based on the specified (or if none specified, the client
# library stored) `token_params` and `auth_options`. Note this can only be used when the API key value is available
# locally. Otherwise, the {Ably::Models::TokenRequest} must be obtained from the key owner. Use this to generate
# an {Ably::Models::TokenRequest} in order to implement an Ably Token request callback for use by other clients.
# Both `token_params` and `auth_options` are optional. When omitted or null, the default token parameters
# and authentication options for the client library are used, as specified in the `client_options` when the client
# library was instantiated, or later updated with an explicit authorize request. Values passed in are used instead
# of, rather than being merged with, the default values. To understand why an {Ably::Models::TokenRequest} may be
# issued to clients in favor of a token, see Token Authentication explained.
#
# @spec RSA9
#
# @param [Hash] token_params the token params used in the token request
# @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+
Expand Down
15 changes: 9 additions & 6 deletions lib/ably/models/auth_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Ably::Models
# @param attributes (see #initialize)
#
# @return [AuthDetails]
#
def self.AuthDetails(attributes)
case attributes
when AuthDetails
Expand All @@ -27,14 +28,16 @@ def initialize(attributes = {})
self.attributes.freeze
end

%w(access_token).each do |attribute|
define_method attribute do
attributes[attribute.to_sym]
end
# The authentication token string.
#
# @spec AD2
#
# @return [String]
#
def access_token
attributes[:access_token]
end

# @!attribute [r] attributes
# @return [Hash] Access the token details Hash object ruby'fied to use symbolized keys
def attributes
@hash_object
end
Expand Down
20 changes: 15 additions & 5 deletions lib/ably/models/channel_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Ably::Models
# @param attributes (see #initialize)
#
# @return [ChannelDetails]
#
def self.ChannelDetails(attributes)
case attributes
when ChannelDetails
Expand All @@ -13,14 +14,17 @@ def self.ChannelDetails(attributes)
end
end

# ChannelDetails is a type that represents information for a channel including channelId, name, status and occupancy (CHD1)
# Contains the details of a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel} object
# such as its ID and {Ably::Models::ChannelStatus}.
#
class ChannelDetails
extend Ably::Modules::Enum
extend Forwardable
include Ably::Modules::ModelCommon

# The attributes of ChannelDetails (CHD2)
# The attributes of ChannelDetails
#
# @spec CHD2
#
attr_reader :attributes

Expand All @@ -32,23 +36,29 @@ def initialize(attrs)
@attributes = IdiomaticRubyWrapper(attrs.clone)
end

# The identifier of the channel (CHD2a)
# The identifier of the channel
#
# @spec CHD2a
#
# @return [String]
#
def channel_id
attributes[:channel_id]
end

# The identifier of the channel (CHD2a)
# The identifier of the channel
#
# @spec CHD2a
#
# @return [String]
#
def name
attributes[:name]
end

# The status of the channel (CHD2b)
# A {Ably::Models::ChannelStatus} object.
#
# @spec CHD2b
#
# @return [Ably::Models::ChannelStatus, nil]
#
Expand Down
39 changes: 31 additions & 8 deletions lib/ably/models/channel_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Ably::Models
# @param attributes (see #initialize)
#
# @return [ChannelMetrics]
#
def self.ChannelMetrics(attributes)
case attributes
when ChannelMetrics
Expand All @@ -13,8 +14,10 @@ def self.ChannelMetrics(attributes)
end
end

# ChannelMetrics is a type that contains the count of publishers and subscribers, connections and presenceConnections,
# presenceMembers and presenceSubscribers (CHM1)
# Contains the metrics associated with a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel},
# such as the number of publishers, subscribers and connections it has.
#
# @spec CHM1
#
class ChannelMetrics
extend Ably::Modules::Enum
Expand All @@ -33,47 +36,67 @@ def initialize(attrs)
@attributes = IdiomaticRubyWrapper(attrs.clone)
end

# The total number of connections to the channel (CHM2a)
# The number of realtime connections attached to the channel.
#
# @spec CHM2a
#
# @return [Integer]
#
def connections
attributes[:connections]
end

# The total number of presence connections to the channel (CHM2b)
# The number of realtime connections attached to the channel with permission to enter the presence set, regardless
# of whether or not they have entered it. This requires the presence capability and for a client to not have specified
# a {Ably::Models::ChannelOptions::MODES} flag that excludes {Ably::Models::ChannelOptions::MODES}#PRESENCE.
#
# @spec CHM2b
#
# @return [Integer]
#
def presence_connections
attributes[:presence_connections]
end

# The total number of presence members for the channel (CHM2c)
# The number of members in the presence set of the channel.
#
# @spec CHM2c
#
# @return [Integer]
#
def presence_members
attributes[:presence_members]
end

# The total number of presence subscribers for the channel (CHM2d)
# The number of realtime attachments receiving presence messages on the channel. This requires the subscribe capability
# and for a client to not have specified a {Ably::Models::ChannelOptions::MODES} flag that excludes
# {Ably::Models::ChannelOptions::MODES}#PRESENCE_SUBSCRIBE.
#
# @spec CHM2d
#
# @return [Integer]
#
def presence_subscribers
attributes[:presence_subscribers]
end

# The total number of publishers to the channel (CHM2e)
# The number of realtime attachments permitted to publish messages to the channel. This requires the publish
# capability and for a client to not have specified a {Ably::Models::ChannelOptions::MODES} flag that excludes
# {Ably::Models::ChannelOptions::MODES}#PUBLISH.
#
# @spec CHM2e
#
# @return [Integer]
#
def publishers
attributes[:publishers]
end

# The total number of subscribers to the channel (CHM2f)
# The number of realtime attachments receiving messages on the channel. This requires the subscribe capability and
# for a client to not have specified a {Ably::Models::ChannelOptions::MODES} flag that excludes
# {Ably::Models::ChannelOptions::MODES}#SUBSCRIBE.
#
# @spec CHM2f
#
# @return [Integer]
#
Expand Down
13 changes: 10 additions & 3 deletions lib/ably/models/channel_occupancy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Ably::Models
# @param attributes (see #initialize)
#
# @return [ChannelOccupancy]
#
def self.ChannelOccupancy(attributes)
case attributes
when ChannelOccupancy
Expand All @@ -13,14 +14,18 @@ def self.ChannelOccupancy(attributes)
end
end

# Type that contain channel metrics (CHO1)
# Contains the metrics of a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel} object.
#
# @spec CHO1
#
class ChannelOccupancy
extend Ably::Modules::Enum
extend Forwardable
include Ably::Modules::ModelCommon

# The attributes of ChannelOccupancy (CH02)
# The attributes of ChannelOccupancy.
#
# @spec CH02
#
attr_reader :attributes

Expand All @@ -32,7 +37,9 @@ def initialize(attrs)
@attributes = IdiomaticRubyWrapper(attrs.clone)
end

# Metrics object (CHO2a)
# A {Ably::Models::ChannelMetrics} object.
#
# @spec CHO2a
#
# @return [Ably::Models::ChannelMetrics, nil]
#
Expand Down
Loading