sleeper_api 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea2a84bc8be057968c5822116b20f53d1dac11550c8baf70d437fab4d72b427a
4
- data.tar.gz: 3c518c6191fc0e117229a10d9ae5f7d1a04d4f8dc62db53c52e8d6af99e6a635
3
+ metadata.gz: d1c3b6b24667fed7fcf31880c435c5fce300c4b21dcef51483144385aa2fd13b
4
+ data.tar.gz: 639011f23fc50f203818f5a035d2c0a15c4e914936d713e10e8b7d357a2d37ef
5
5
  SHA512:
6
- metadata.gz: 5e248beba16cf5d2ebba74570ce4856ddcefa4fa95a8c118e685d2e89ca57eea31268c848bcfc59501b25f40d0bb08bfd8c4f65d4f9f2129f799b5f8d829c053
7
- data.tar.gz: 060bef1860b827761fdcbfc38e65e0a0a5ec4b1abb6da4e2e52d43416a400e3c574135ed4001363049728cf47f34d64e13465f9cfc00067f1c1ab03cb770e076
6
+ metadata.gz: '091314d14034dfa63a1ebc505e83c457bcbb08e4553e032f08b67917a7d6e6507572aabbc426a00999c770c46d554c48484e64b7a491b615fc97814ef031fd27'
7
+ data.tar.gz: 03e6caa336e7ff7be7965da2644f2086031a727b0d9eb47824fa1ddf372b74e8ea1f620832304a372169d6ef49b9ef33b2878493ec2da97e690fdabdd072bb4b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [1.10.0] - 2026-10-14
2
+
3
+ ### Changed
4
+
5
+ - **`config.timeout` accepts 1 to 60 seconds, fractions included** (was 10 to
6
+ 60, whole or not). A caller holding a web request open needs to give up in a
7
+ second or two: a `/v1/user/{name}` lookup answers in 0.09–0.22s (median
8
+ 0.12s, 30 calls, measured 2026-10-13), so the old 10-second floor held a
9
+ thread ten times longer than any answer takes. A non-number now raises
10
+ `SleeperApi::Error` rather than `NoMethodError`.
11
+
1
12
  ## [1.9.0] - 2026-10-09
2
13
 
3
14
  ### Added
data/CLAUDE.md CHANGED
@@ -25,7 +25,7 @@ CI (`.github/workflows/ci.yml`) runs `bundle exec rake ci` on Ruby 3.2 and 3.4.
25
25
 
26
26
  Four layers, with a deliberate split between HTTP and modeling:
27
27
 
28
- - **`SleeperApi`** (`lib/sleeper_api.rb`) — module-level config + memoized global `SleeperApi.client`. `Configuration` validates `timeout` (10–60) and `retries` (0–5), raising `SleeperApi::Error` outside those bounds.
28
+ - **`SleeperApi`** (`lib/sleeper_api.rb`) — module-level config + memoized global `SleeperApi.client`. `Configuration` validates `timeout` (1–60, fractions allowed; 10–60 before 1.10.0) and `retries` (0–5), raising `SleeperApi::Error` outside those bounds.
29
29
  - **`Client`** — the only thing that talks HTTP. `include HTTParty` with `base_uri "https://api.sleeper.app"` — **the bare host; the `/v1` lives in each path**. That is deliberate and load-bearing: not every Sleeper endpoint is versioned. `/schedule/{sport}/{season_type}/{season}` is served from the host root, and while `base_uri` carried the version that endpoint was unreachable at any path a caller could pass in. A new endpoint spells out where it lives; do not move the version back into `base_uri` to shorten the paths.
30
30
 
31
31
  Every call funnels through the private `make_request`, which handles retry-on-timeout, logging, and converts non-2xx into `SleeperApi::Error` — and, since 1.5.1, **every connection failure too** (`CONNECTION_ERRORS`: `SocketError`, `SystemCallError`, `OpenSSL::SSL::SSLError`, `EOFError`), unretried, as `"Could not reach <path>: …"`. A consumer can rescue `SleeperApi::Error` alone and see every way a call fails. **That error quotes the path**, so the path prefix is part of a public string — v1.2.0 changed it from `"Failed to fetch /user/x: 404"` to `"Failed to fetch /v1/user/x: 404"`. `Client` also owns the 24-hour in-memory player cache.
data/README.md CHANGED
@@ -53,7 +53,7 @@ Customize the gem's behavior:
53
53
 
54
54
  ```ruby
55
55
  SleeperApi.configure do |config|
56
- config.timeout = 45 # Request timeout in seconds (10-60)
56
+ config.timeout = 45 # Request timeout in seconds (1-60, fractions allowed)
57
57
  config.retries = 5 # Number of retries on failure (0-5)
58
58
  config.logger = Logger.new(STDOUT) # Custom logger
59
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SleeperApi
4
- VERSION = "1.9.0"
4
+ VERSION = "1.10.0"
5
5
  end
data/lib/sleeper_api.rb CHANGED
@@ -50,14 +50,16 @@ module SleeperApi
50
50
 
51
51
  # Configuration for SleeperApi client behavior.
52
52
  #
53
- # @attr timeout [Integer] HTTP request timeout (10-60 seconds)
53
+ # @attr timeout [Numeric] HTTP request timeout (1-60 seconds; fractions allowed)
54
54
  # @attr retries [Integer] Maximum retry attempts (0-5)
55
55
  # @attr logger [Logger, nil] Logger for debugging requests
56
56
  class Configuration
57
57
  attr_accessor :logger
58
58
  attr_reader :timeout, :retries
59
59
 
60
- MIN_TIMEOUT = 10
60
+ # 1, not 10: a caller holding a web request open needs to give up in a
61
+ # second or two (a lookup answers in ~0.1s), not ten.
62
+ MIN_TIMEOUT = 1
61
63
  MAX_TIMEOUT = 60
62
64
  MIN_RETRIES = 0
63
65
  MAX_RETRIES = 5
@@ -70,10 +72,10 @@ module SleeperApi
70
72
 
71
73
  # Set HTTP timeout with validation.
72
74
  #
73
- # @param value [Integer] Timeout in seconds
74
- # @raise [SleeperApi::Error] If outside valid range
75
+ # @param value [Numeric] Timeout in seconds, e.g. 2.5
76
+ # @raise [SleeperApi::Error] If not a number in the valid range
75
77
  def timeout=(value)
76
- unless value.between?(MIN_TIMEOUT, MAX_TIMEOUT)
78
+ unless value.is_a?(Numeric) && value.between?(MIN_TIMEOUT, MAX_TIMEOUT)
77
79
  raise SleeperApi::Error, "Timeout must be between #{MIN_TIMEOUT} and #{MAX_TIMEOUT} seconds"
78
80
  end
79
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sleeper_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eruity1