http-retry-after 0.1.0 → 0.1.1
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 +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/.github/workflows/release-please.yml +35 -0
- data/AGENTS.md +38 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +2 -2
- data/README.md +4 -2
- data/http-retry-after.gemspec +2 -2
- data/lib/http/retry_after/version.rb +1 -1
- data/lib/http/retry_after.rb +5 -2
- data/renovate.json +6 -0
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5cba00245cea0af17f0af45b2fed6bf791ffc0fc0ece1d63174fdd0b4f9bd21b
|
|
4
|
+
data.tar.gz: 12520273c74bbf845c3b050e00aed56162bdb9ee76017fff94eff788686847a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9af7b8a8975f9d7fa2996d9f40f2870ef2e903ab5bec3d23940230196145800a3188b0d9d8bc6decd712be16ad26206682e3984e089e18f1fa1c759109f73d90
|
|
7
|
+
data.tar.gz: 866dc47b25b8609c834265434b75990ef4c401ce952a22af1dfcfafbe323dd523bb4f871e86d9b80ed490ada34d454259257e00ae25197813616fff5a95299e6
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -14,8 +14,8 @@ jobs:
|
|
|
14
14
|
ruby: ["3.1", "3.2", "3.3", "3.4"]
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
|
-
- uses: actions/checkout@
|
|
18
|
-
- uses: ruby/setup-ruby@
|
|
17
|
+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
18
|
+
- uses: ruby/setup-ruby@4c24fa5ec04b2e79eb40571b1cee2a0d2b705771 # v1.278.0
|
|
19
19
|
with:
|
|
20
20
|
ruby-version: ${{ matrix.ruby }}
|
|
21
21
|
bundler-cache: true
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: release-please
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
pull-requests: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release-please:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
outputs:
|
|
16
|
+
release_created: ${{ steps.release.outputs.release_created }}
|
|
17
|
+
steps:
|
|
18
|
+
- id: release
|
|
19
|
+
uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
|
|
20
|
+
with:
|
|
21
|
+
release-type: ruby
|
|
22
|
+
deploy:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
needs:
|
|
25
|
+
- release-please
|
|
26
|
+
if: ${{ needs.release-please.outputs.release_created }}
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
29
|
+
- uses: ruby/setup-ruby@4c24fa5ec04b2e79eb40571b1cee2a0d2b705771 # v1.278.0
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: "3.3"
|
|
32
|
+
- run: gem build http-retry-after.gemspec
|
|
33
|
+
- run: gem push pkg/http-retry-after-*.gem
|
|
34
|
+
env:
|
|
35
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Repository Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
4
|
+
|
|
5
|
+
- Core implementation: `lib/http/retry_after.rb` contains parsing logic; `lib/http/retry_after/version.rb` holds the version. `http-retry-after.gemspec` defines gem metadata and Ruby requirement (>= 3.0).
|
|
6
|
+
- Tests: Minitest specs in `test/**/*_test.rb`; default Rake task runs them. `test/test_helper.rb` sets load paths and requires the gem.
|
|
7
|
+
- Build outputs: `pkg/` is used for built gems. `CHANGELOG.md` tracks releases; `LICENSE.txt` is MIT.
|
|
8
|
+
|
|
9
|
+
## Setup and Development
|
|
10
|
+
|
|
11
|
+
- Install dependencies: `bundle install`.
|
|
12
|
+
- Run tests: `bundle exec rake test` (or `bundle exec rake`; default task is test).
|
|
13
|
+
- REPL check: `bundle exec irb -Ilib -rhttp/retry_after` to try parsing helpers interactively.
|
|
14
|
+
- Build gem: `gem build http-retry-after.gemspec`; keep `pkg/` clean between builds.
|
|
15
|
+
- Release CI Ruby version: set `release-please.yml` `ruby-version` to the stable version used in CI matrix (prefer latest stable; update when CI matrix changes).
|
|
16
|
+
|
|
17
|
+
## Coding Style and Naming
|
|
18
|
+
|
|
19
|
+
- Ruby 2-space indentation; keep `# frozen_string_literal: true` at the top of Ruby files.
|
|
20
|
+
- Public API: `HTTP::RetryAfter.parse`, `parse_seconds`, `parse_http_date`. Reuse `NegativeRetryAfterError` and `InvalidFormatError`; keep messages aligned with `"Invalid Retry-After value: ..."` style.
|
|
21
|
+
- Keep rescue blocks minimal; rely on `Integer(...)` and `Time.httpdate` behavior for parsing. Avoid new external dependencies or monkey patches.
|
|
22
|
+
|
|
23
|
+
## Testing Guidelines
|
|
24
|
+
|
|
25
|
+
- Framework: Minitest. Add cases to `*_test.rb`, using existing assertions (`assert_raises`, `assert_in_delta`) as patterns.
|
|
26
|
+
- Time-sensitive logic: wrap `Time.now` calculations with `assert_in_delta`; cover boundaries (negative values, nil, malformed strings).
|
|
27
|
+
- Run `bundle exec rake test` before PRs; add regression tests when altering time math or error handling.
|
|
28
|
+
|
|
29
|
+
## Commit and Pull Request
|
|
30
|
+
|
|
31
|
+
- Commit style mirrors current history: Conventional Commits-like prefixes (`feat|fix|chore|docs: ...`) with issue numbers `(#123)` when relevant.
|
|
32
|
+
- PRs: include summary, motivation, key changes, and test results as bullets. Update `CHANGELOG.md` for user-visible changes.
|
|
33
|
+
- Keep one concern per PR, ensure Rake tests pass, and attach repro steps or screenshots only when helpful.
|
|
34
|
+
|
|
35
|
+
## Security and Maintenance
|
|
36
|
+
|
|
37
|
+
- Do not commit secrets. Treat header values as untrusted input; preserve validation and consistent exceptions.
|
|
38
|
+
- Renovate (`renovate.json`) updates dependencies; confirm tests/CI before merging. If Ruby version requirements change, update the gemspec and README together.
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.1.1](https://github.com/kudoas/http-retry-after/compare/v0.1.0...v0.1.1) (2026-01-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* improve error handling in parse_seconds and parse_http_date methods ([#4](https://github.com/kudoas/http-retry-after/issues/4)) ([558c11b](https://github.com/kudoas/http-retry-after/commit/558c11b81f04bb9184bd1678b4c20d819c05d6e7))
|
|
11
|
+
|
|
5
12
|
## [Unreleased]
|
|
6
13
|
|
|
7
14
|
- No changes yet.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# http-retry-after
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/http-retry-after)
|
|
4
|
+
|
|
3
5
|
`http-retry-after` is a Ruby gem for parsing HTTP `Retry-After` header values and converting them into Ruby `Time` instances, so clients can respect server retry policies defined in RFC 9110 without reimplementing parsing logic.
|
|
4
6
|
|
|
5
7
|
## What is Retry-After?
|
|
@@ -11,7 +13,7 @@ The HTTP `Retry-After` response header, defined in [RFC 9110, Section 10.2.2](ht
|
|
|
11
13
|
Require the gem and call `HTTP::RetryAfter.parse` with either a delta-seconds value or an HTTP-date string:
|
|
12
14
|
|
|
13
15
|
```ruby
|
|
14
|
-
require "http
|
|
16
|
+
require "http/retry-after"
|
|
15
17
|
|
|
16
18
|
# Delta-seconds value (interpreted as seconds from now)
|
|
17
19
|
HTTP::RetryAfter.parse("120")
|
|
@@ -53,7 +55,7 @@ Both helpers return a `Time` object. `parse_seconds` uses `Time.now + seconds`,
|
|
|
53
55
|
Add this line to your application's Gemfile:
|
|
54
56
|
|
|
55
57
|
```ruby
|
|
56
|
-
gem "http-retry-after"
|
|
58
|
+
gem "http-retry-after"
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
And then execute:
|
data/http-retry-after.gemspec
CHANGED
|
@@ -6,9 +6,9 @@ Gem::Specification.new do |spec|
|
|
|
6
6
|
spec.name = "http-retry-after"
|
|
7
7
|
spec.version = HTTP::RetryAfter::VERSION
|
|
8
8
|
spec.authors = ["Daichi KUDO"]
|
|
9
|
-
spec.summary = "A Ruby
|
|
9
|
+
spec.summary = "A Ruby gem for handling HTTP Retry-After headers."
|
|
10
10
|
spec.description = <<~DESC
|
|
11
|
-
HTTP::RetryAfter is a Ruby
|
|
11
|
+
HTTP::RetryAfter is a Ruby gem that provides functionality to parse and handle HTTP Retry-After headers, which indicate how long a client should wait before making a follow-up request.
|
|
12
12
|
DESC
|
|
13
13
|
spec.homepage = "https://github.com/kudoas/http-retry-after"
|
|
14
14
|
spec.license = "MIT"
|
data/lib/http/retry_after.rb
CHANGED
|
@@ -17,17 +17,20 @@ module HTTP
|
|
|
17
17
|
def self.parse_seconds(retry_after)
|
|
18
18
|
seconds = begin
|
|
19
19
|
Integer(retry_after)
|
|
20
|
-
rescue
|
|
20
|
+
rescue TypeError, ArgumentError
|
|
21
21
|
raise InvalidFormatError, "Invalid Retry-After value: #{retry_after.inspect}"
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
raise NegativeRetryAfterError, "Negative Retry-After value: #{seconds}" if seconds.negative?
|
|
25
|
+
|
|
25
26
|
Time.now + seconds
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
def self.parse_http_date(retry_after)
|
|
30
|
+
raise InvalidFormatError, "Invalid Retry-After value: #{retry_after.inspect}" if retry_after.nil?
|
|
31
|
+
|
|
29
32
|
Time.httpdate(retry_after)
|
|
30
|
-
rescue
|
|
33
|
+
rescue ArgumentError, NoMethodError, TypeError
|
|
31
34
|
raise InvalidFormatError, "Invalid Retry-After value: #{retry_after.inspect}"
|
|
32
35
|
end
|
|
33
36
|
end
|
data/renovate.json
ADDED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: http-retry-after
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daichi KUDO
|
|
@@ -9,7 +9,7 @@ bindir: bin
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description: 'HTTP::RetryAfter is a Ruby
|
|
12
|
+
description: 'HTTP::RetryAfter is a Ruby gem that provides functionality to parse
|
|
13
13
|
and handle HTTP Retry-After headers, which indicate how long a client should wait
|
|
14
14
|
before making a follow-up request.
|
|
15
15
|
|
|
@@ -19,7 +19,9 @@ extensions: []
|
|
|
19
19
|
extra_rdoc_files: []
|
|
20
20
|
files:
|
|
21
21
|
- ".github/workflows/ci.yml"
|
|
22
|
+
- ".github/workflows/release-please.yml"
|
|
22
23
|
- ".gitignore"
|
|
24
|
+
- AGENTS.md
|
|
23
25
|
- CHANGELOG.md
|
|
24
26
|
- Gemfile
|
|
25
27
|
- Gemfile.lock
|
|
@@ -30,6 +32,7 @@ files:
|
|
|
30
32
|
- lib/http-retry-after.rb
|
|
31
33
|
- lib/http/retry_after.rb
|
|
32
34
|
- lib/http/retry_after/version.rb
|
|
35
|
+
- renovate.json
|
|
33
36
|
- test/http_retry_after_test.rb
|
|
34
37
|
- test/test_helper.rb
|
|
35
38
|
homepage: https://github.com/kudoas/http-retry-after
|
|
@@ -52,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
52
55
|
- !ruby/object:Gem::Version
|
|
53
56
|
version: '0'
|
|
54
57
|
requirements: []
|
|
55
|
-
rubygems_version:
|
|
58
|
+
rubygems_version: 4.0.3
|
|
56
59
|
specification_version: 4
|
|
57
|
-
summary: A Ruby
|
|
60
|
+
summary: A Ruby gem for handling HTTP Retry-After headers.
|
|
58
61
|
test_files: []
|