Skip to content

Commit ca6ae63

Browse files
authored
Merge pull request #100 from dblock/claude-doc
Add comprehensive RDoc documentation across entire codebase
2 parents 3c3c9f0 + 94b94cb commit ca6ae63

File tree

104 files changed

+4477
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4477
-266
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
### 3.0.1 (Next)
1+
### 3.1.0 (Next)
22

3+
* [#100](https://github.com/dblock/strava-ruby-client/pull/100): Adds comprehensive rdoc documentation - [@dblock](https://github.com/dblock).
34
* Your contribution here.
45

56
### 3.0.0 (2025/10/24)

lib/strava/api/client.rb

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
module Strava
44
module Api
5+
#
6+
# Main API client for interacting with the Strava API v3.
7+
#
8+
# This class provides a complete Ruby interface to the Strava API, including support for:
9+
# * Activities (create, read, update, list)
10+
# * Athletes (profile, stats, zones)
11+
# * Clubs (details, members, activities)
12+
# * Gear (equipment details)
13+
# * Routes (details, GPX/TCX export)
14+
# * Segments and Segment Efforts
15+
# * Streams (activity, route, segment data)
16+
# * Uploads (activity file uploads)
17+
# * OAuth (token refresh, deauthorization)
18+
#
19+
# @example Create a client with an access token
20+
# client = Strava::Api::Client.new(access_token: "your_access_token")
21+
# athlete = client.athlete
22+
# activities = client.athlete_activities(per_page: 10)
23+
#
24+
# @example Configure globally
25+
# Strava::Api::Client.configure do |config|
26+
# config.access_token = "your_access_token"
27+
# end
28+
# client = Strava::Api::Client.new
29+
#
30+
# @see https://developers.strava.com/docs/reference/ Strava API Documentation
31+
#
532
class Client < Strava::Web::Client
633
include Endpoints::Activities
734
include Endpoints::Athletes
@@ -16,22 +43,64 @@ class Client < Strava::Web::Client
1643

1744
attr_accessor(*Config::ATTRIBUTES)
1845

46+
#
47+
# Initialize a new API client.
48+
#
49+
# @param [Hash] options Configuration options for the client
50+
# @option options [String] :access_token OAuth access token for API authentication (required)
51+
# @option options [String] :endpoint API endpoint URL (defaults to https://www.strava.com/api/v3)
52+
# @option options [String] :user_agent User agent string for HTTP requests
53+
# @option options [Logger] :logger Logger instance for request/response logging
54+
# @option options [Integer] :timeout HTTP request timeout in seconds
55+
# @option options [Integer] :open_timeout HTTP connection timeout in seconds
56+
# @option options [String] :proxy HTTP proxy URL
57+
# @option options [String] :ca_path Path to SSL CA certificates
58+
# @option options [String] :ca_file Path to SSL CA certificate file
59+
#
60+
# @example
61+
# client = Strava::Api::Client.new(
62+
# access_token: "your_access_token",
63+
# user_agent: "My Strava App/1.0"
64+
# )
65+
#
1966
def initialize(options = {})
2067
Config::ATTRIBUTES.each do |key|
2168
send("#{key}=", options[key] || Strava::Api.config.send(key))
2269
end
2370
super
2471
end
2572

73+
#
74+
# Returns HTTP headers for API requests.
75+
#
76+
# @return [Hash] Headers including OAuth bearer token authorization
77+
# @api private
78+
#
2679
def headers
2780
{ 'Authorization' => "Bearer #{access_token}" }
2881
end
2982

3083
class << self
84+
#
85+
# Configure the API client globally.
86+
#
87+
# @yield [Config] Configuration object
88+
# @return [Strava::Api::Config] Configuration object
89+
#
90+
# @example
91+
# Strava::Api::Client.configure do |config|
92+
# config.access_token = "your_access_token"
93+
# end
94+
#
3195
def configure
3296
block_given? ? yield(Config) : Config
3397
end
3498

99+
#
100+
# Returns the configuration object.
101+
#
102+
# @return [Strava::Api::Config] Configuration object
103+
#
35104
def config
36105
Config
37106
end

lib/strava/api/config.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,67 @@
22

33
module Strava
44
module Api
5+
#
6+
# Configuration module for the Strava API client.
7+
#
8+
# This module manages configuration settings for the API client, including
9+
# the API endpoint URL and access token for authentication.
10+
#
11+
# @example Configure the API client
12+
# Strava::Api.configure do |config|
13+
# config.access_token = 'your_access_token_here'
14+
# end
15+
#
16+
# @example Access current configuration
17+
# Strava::Api.config.endpoint
18+
# # => 'https://www.strava.com/api/v3'
19+
#
520
module Config
621
extend self
722

23+
# @return [Array<Symbol>] List of configurable attributes
824
ATTRIBUTES = %i[
925
endpoint
1026
access_token
1127
].freeze
1228

1329
attr_accessor(*Config::ATTRIBUTES)
1430

31+
#
32+
# Reset configuration to default values.
33+
#
34+
# Sets the endpoint to the default Strava API v3 URL and
35+
# clears the access token.
36+
#
37+
# @return [void]
38+
#
1539
def reset
1640
self.endpoint = 'https://www.strava.com/api/v3'
1741
self.access_token = nil
1842
end
1943
end
2044

2145
class << self
46+
#
47+
# Configure the API client with a block.
48+
#
49+
# @yield [Config] Yields the configuration module for setup
50+
# @return [Module] The Config module
51+
#
52+
# @example
53+
# Strava::Api.configure do |config|
54+
# config.access_token = ENV['STRAVA_ACCESS_TOKEN']
55+
# end
56+
#
2257
def configure
2358
block_given? ? yield(Config) : Config
2459
end
2560

61+
#
62+
# Returns the current API configuration.
63+
#
64+
# @return [Module] The Config module
65+
#
2666
def config
2767
Config
2868
end

lib/strava/api/cursor.rb

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,42 @@
22

33
module Strava
44
module Api
5+
#
6+
# Handles paginated iteration through API endpoints.
7+
#
8+
# This class provides an Enumerable interface for iterating through
9+
# paginated API responses. It supports both traditional page-based
10+
# pagination and cursor-based pagination.
11+
#
12+
# @see Strava::Api::Pagination
13+
#
14+
# @example Iterating through pages
15+
# cursor = Strava::Api::Cursor.new(client, 'athlete/activities', per_page: 30)
16+
# cursor.each do |page|
17+
# page.each do |activity|
18+
# puts activity.name
19+
# end
20+
# end
21+
#
522
class Cursor
623
include Enumerable
724

8-
attr_reader :client, :path, :params
25+
# @return [Strava::Api::Client] API client instance
26+
attr_reader :client
927

28+
# @return [String] API endpoint path
29+
attr_reader :path
30+
31+
# @return [Hash] Query parameters for the request
32+
attr_reader :params
33+
34+
#
35+
# Initialize a new Cursor for paginated iteration.
36+
#
37+
# @param client [Strava::Api::Client] API client to use for requests
38+
# @param path [String] API endpoint path to paginate
39+
# @param params [Hash] Query parameters (excluding :limit which is removed)
40+
#
1041
def initialize(client, path, params = {})
1142
@client = client
1243
@path = path

0 commit comments

Comments
 (0)