w3c_api 0.1.7 → 0.3.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 +4 -4
- data/.rubocop_todo.yml +10 -13
- data/lib/w3c_api/hal.rb +41 -3
- data/lib/w3c_api/version.rb +1 -1
- metadata +47 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: aca3cfabd692c0eaada3c4a188537a3609bd49f79001e15394648e05651a604a
|
|
4
|
+
data.tar.gz: cf15b6dc9c61577fd758d014e501b95891be435665b68e28d9b33343f3101381
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8d9c16aeb023ee84208ee83d9448514e7f527673a882234aa1621f736c526b19f129086ceb1657ed17ec5b016c220a1c86ebb1046a9c34cc7c581da9eb271ed
|
|
7
|
+
data.tar.gz: 4a1055ebd67f8afdb6ecb33da8088ecb0b7b0ffdfd694e52f7dbd1e9e8d79d44c6fb9729a06acafbdb00667e6338da97fa2cd410eff776b65ea53bc925ceff3c
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2026-04-16 07:40:06 UTC using RuboCop version 1.86.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
Gemspec/RequiredRubyVersion:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'w3c_api.gemspec'
|
|
13
|
+
|
|
9
14
|
# Offense count: 4
|
|
10
15
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
11
16
|
Metrics/AbcSize:
|
|
@@ -21,18 +26,10 @@ Metrics/CyclomaticComplexity:
|
|
|
21
26
|
Exclude:
|
|
22
27
|
- 'demo/test_embed_functionality.rb'
|
|
23
28
|
|
|
24
|
-
# Offense count: 3
|
|
25
|
-
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
26
|
-
Metrics/MethodLength:
|
|
27
|
-
Max: 351
|
|
28
|
-
Exclude:
|
|
29
|
-
- 'demo/test_embed_functionality.rb'
|
|
30
|
-
- 'lib/w3c_api/commands/specification.rb'
|
|
31
|
-
- 'lib/w3c_api/hal.rb'
|
|
32
|
-
|
|
33
29
|
# Offense count: 1
|
|
34
|
-
# Configuration parameters:
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates.
|
|
31
|
+
# AllowedMethods: call
|
|
32
|
+
# WaywardPredicates: infinite?, nonzero?
|
|
33
|
+
Naming/PredicateMethod:
|
|
37
34
|
Exclude:
|
|
38
35
|
- 'lib/w3c_api/hal.rb'
|
data/lib/w3c_api/hal.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "singleton"
|
|
4
|
+
require "faraday/retry"
|
|
4
5
|
require "lutaml/hal"
|
|
5
6
|
require_relative "models"
|
|
6
7
|
|
|
@@ -50,18 +51,55 @@ module W3cApi
|
|
|
50
51
|
def client
|
|
51
52
|
@client ||= Lutaml::Hal::Client.new(
|
|
52
53
|
api_url: API_URL,
|
|
54
|
+
connection: connection,
|
|
53
55
|
rate_limiting: rate_limiting_options,
|
|
54
56
|
)
|
|
55
57
|
end
|
|
56
58
|
|
|
59
|
+
# Faraday connection mirroring lutaml-hal's default middleware stack, with a
|
|
60
|
+
# retry layer for the failures lutaml-hal's RateLimiter does not cover: the
|
|
61
|
+
# W3C API signals rate-limiting with HTTP 403, plus transient connection and
|
|
62
|
+
# timeout errors. (lutaml-hal still retries 429 and 5xx.) Owning retries here
|
|
63
|
+
# means every consumer of the client is resilient without its own wrapper.
|
|
64
|
+
def connection
|
|
65
|
+
@connection ||= Faraday.new(url: API_URL.delete_suffix("/")) do |conn|
|
|
66
|
+
conn.request :retry, retry_options
|
|
67
|
+
conn.use Faraday::FollowRedirects::Middleware
|
|
68
|
+
conn.request :json
|
|
69
|
+
conn.response :json, content_type: /\bjson$/
|
|
70
|
+
conn.adapter Faraday.default_adapter
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Retry policy for the W3C-specific transient failures (HTTP 403 and
|
|
75
|
+
# connection/timeout). Grows 1, 2, 4, 8, 16s, matching rate_limiting_options.
|
|
76
|
+
def retry_options
|
|
77
|
+
{
|
|
78
|
+
max: 5,
|
|
79
|
+
interval: 1.0,
|
|
80
|
+
backoff_factor: 2,
|
|
81
|
+
max_interval: 30.0,
|
|
82
|
+
retry_statuses: [403],
|
|
83
|
+
exceptions: [
|
|
84
|
+
Errno::ETIMEDOUT, Timeout::Error,
|
|
85
|
+
Faraday::TimeoutError, Faraday::ConnectionFailed
|
|
86
|
+
],
|
|
87
|
+
}
|
|
88
|
+
end
|
|
89
|
+
|
|
57
90
|
# Configure rate limiting options
|
|
91
|
+
#
|
|
92
|
+
# lutaml-hal's RateLimiter retries 429 and 5xx responses with exponential
|
|
93
|
+
# backoff (base_delay * backoff_factor**(attempt - 1), capped at max_delay).
|
|
94
|
+
# These defaults grow 1, 2, 4, 8, 16s so a rate-limited or briefly
|
|
95
|
+
# overloaded W3C API is given real room to recover during a bulk crawl.
|
|
58
96
|
def rate_limiting_options
|
|
59
97
|
@rate_limiting_options ||= {
|
|
60
98
|
enabled: true,
|
|
61
99
|
max_retries: 5,
|
|
62
|
-
base_delay: 0
|
|
63
|
-
max_delay:
|
|
64
|
-
backoff_factor:
|
|
100
|
+
base_delay: 1.0,
|
|
101
|
+
max_delay: 30.0,
|
|
102
|
+
backoff_factor: 2.0,
|
|
65
103
|
}
|
|
66
104
|
end
|
|
67
105
|
|
data/lib/w3c_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: w3c_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-06-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -38,20 +38,62 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: faraday-retry
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: lutaml-hal
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
44
58
|
requirements:
|
|
45
59
|
- - "~>"
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.
|
|
61
|
+
version: 0.2.0
|
|
48
62
|
type: :runtime
|
|
49
63
|
prerelease: false
|
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
65
|
requirements:
|
|
52
66
|
- - "~>"
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 0.
|
|
68
|
+
version: 0.2.0
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: lutaml-model
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.8.0
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.8.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: nokogiri
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
55
97
|
- !ruby/object:Gem::Dependency
|
|
56
98
|
name: rainbow
|
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -159,6 +201,7 @@ metadata:
|
|
|
159
201
|
homepage_uri: https://github.com/relaton/w3c-api
|
|
160
202
|
source_code_uri: https://github.com/relaton/w3c-api
|
|
161
203
|
changelog_uri: https://github.com/relaton/w3c-api
|
|
204
|
+
rubygems_mfa_required: 'true'
|
|
162
205
|
post_install_message:
|
|
163
206
|
rdoc_options: []
|
|
164
207
|
require_paths:
|