ecfr 1.0.5 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/ecfr/client.rb +8 -3
- data/lib/ecfr/renderer_service/diff.rb +15 -8
- data/lib/ecfr/version.rb +1 -1
- data/lib/ecfr/versioner_service/ancestors.rb +32 -10
- data/lib/ecfr/versioner_service/structure.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3982b2145a3ab849c7fbbe13699265d5d3c75ca19be019e8b3e57bad78f6c2ee
|
4
|
+
data.tar.gz: 2d4b94aa527179914dce1d89f6f781bde99af455abddccb8d1c409d199a811be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964a37efcba4b38cbca2c9108f59ef9f972ab23f1b6904149b59bc3105370c351781f166397a9bb97fd9564e91cbc21f89ded0defcb64d678e57636b42db309b
|
7
|
+
data.tar.gz: 55fefed80cbf964968660b8c625cf35189d21c55611bbfa0143ce3394e3408d5d5253817f73c115f7f53d0844b8afaf04d5e828c6d563ee1b947325799157f00
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.0.8] - 2023-05-05
|
4
|
+
### Updates
|
5
|
+
- Update Ecfr::RenderService::Diff to rescue expected error types and raise more specific diff errors
|
6
|
+
|
7
|
+
## [1.0.7] - 2023-05-04
|
8
|
+
### Bugfixes
|
9
|
+
- Remove change to .build method signature that was unnecessary and caused issues with the testing extensions we provide.
|
10
|
+
- Includes bugfix from 1.0.6
|
11
|
+
|
12
|
+
## [1.0.6] - 2023-05-04 (yanked)
|
13
|
+
### Bugfixes
|
14
|
+
- Properly cache ancestor base response (fbfdf1e6)
|
15
|
+
|
3
16
|
## [1.0.5] - 2023-04-24
|
4
17
|
### Bugfixes
|
5
18
|
- Remove blank response body check in PDF generation that doesn't play well with all encodings
|
data/lib/ecfr/client.rb
CHANGED
@@ -135,9 +135,12 @@ module Ecfr
|
|
135
135
|
RequestStore.fetch(cache_key) do
|
136
136
|
puts "Request not in eCFR gem cache, fetching..."
|
137
137
|
|
138
|
-
response = fetch(method, path, params: params,
|
138
|
+
response = fetch(method, path, params: params,
|
139
|
+
client_options: client_options)
|
139
140
|
|
140
|
-
|
141
|
+
if respond_to?(:cache_base_response, true)
|
142
|
+
cache_base_response(response, method, path, params)
|
143
|
+
end
|
141
144
|
|
142
145
|
response
|
143
146
|
end
|
@@ -187,7 +190,9 @@ module Ecfr
|
|
187
190
|
#
|
188
191
|
# See the .perform/.fetch method for argument signatures
|
189
192
|
#
|
190
|
-
def self.build(response:,
|
193
|
+
def self.build(response:,
|
194
|
+
request_data: {}, build_options: {})
|
195
|
+
|
191
196
|
default_build_options = {parse_response: true}
|
192
197
|
build_options = default_build_options.merge(build_options)
|
193
198
|
|
@@ -17,14 +17,21 @@ module Ecfr
|
|
17
17
|
view_mode = options.delete(:view_mode) || :enhanced
|
18
18
|
params = hierarchy.merge(options).merge(compare: old_date)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
begin
|
21
|
+
new(
|
22
|
+
{
|
23
|
+
html: get(
|
24
|
+
content_path(new_date, title, view_mode: view_mode),
|
25
|
+
params
|
26
|
+
).body
|
27
|
+
}.stringify_keys
|
28
|
+
)
|
29
|
+
rescue Ecfr::Client::ResponseError, Ecfr::Client::ServerError
|
30
|
+
# diff too large - diff service generated broken pipe error or 500 code
|
31
|
+
raise DiffTooLarge
|
32
|
+
rescue Ecfr::Client::UnknownStatusCode
|
33
|
+
raise Undiffable
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
data/lib/ecfr/version.rb
CHANGED
@@ -86,7 +86,7 @@ module Ecfr
|
|
86
86
|
perform(
|
87
87
|
:get,
|
88
88
|
ancestors_path(date, title_number),
|
89
|
-
params: options
|
89
|
+
params: options.compact
|
90
90
|
)
|
91
91
|
end
|
92
92
|
|
@@ -97,25 +97,47 @@ module Ecfr
|
|
97
97
|
|
98
98
|
# these parameters add items to the base response but do not affect our
|
99
99
|
# ability to cache that base response
|
100
|
-
PARAMETERS_NOT_AFFECTING_BASE_RESPONSE = %
|
100
|
+
PARAMETERS_NOT_AFFECTING_BASE_RESPONSE = %i[metadata]
|
101
|
+
SIDELOAD_PARAMETERS = %i[structure descendant_depth]
|
101
102
|
|
102
103
|
# if the request only includes optional parameters that don't affect the
|
103
|
-
# basic part of the response, then we can
|
104
|
+
# basic part of the response, then we can cache a base form of that
|
104
105
|
# response by removing those optional return items (this keeps the cache
|
105
106
|
# consistent across request by not including extra items).
|
106
|
-
def self.cache_base_response(response, path, params)
|
107
|
-
|
108
|
-
|
107
|
+
def self.cache_base_response(response, method, path, params)
|
108
|
+
non_hierarchy_params = params.except(
|
109
|
+
*Ecfr::Constants::Hierarchy::HIERARCHY_LEVELS.map(&:to_sym)
|
110
|
+
)
|
111
|
+
|
112
|
+
if only_safe_params?(non_hierarchy_params)
|
113
|
+
cache_key = cache_key(method, path, params.except(*SIDELOAD_PARAMETERS))
|
114
|
+
|
115
|
+
# in the case the the response is the base response the cache keys
|
116
|
+
# will match - fetch will just return that and this will essentially
|
117
|
+
# be a no op
|
109
118
|
RequestStore.fetch(cache_key) do
|
110
|
-
|
119
|
+
excluded_items = params.key?(:metadata) ?
|
120
|
+
[:structure] : [:metadata, :structure]
|
121
|
+
|
122
|
+
response_body = JSON.parse(response.body)
|
123
|
+
.except(*excluded_items.map(&:to_s))
|
124
|
+
|
125
|
+
# return a ducktyped object like the response object
|
126
|
+
OpenStruct.new(
|
127
|
+
body: response_body.to_json,
|
128
|
+
status: response.status
|
129
|
+
)
|
111
130
|
end
|
112
131
|
end
|
113
132
|
end
|
114
|
-
private_class_method :cache_base_response
|
133
|
+
# private_class_method :cache_base_response
|
115
134
|
|
116
135
|
def self.only_safe_params?(params)
|
117
|
-
# are all of the params keys included in the
|
118
|
-
params.keys.all?
|
136
|
+
# are all of the params keys included in the one of the lists?
|
137
|
+
params.keys.all? do |p|
|
138
|
+
(PARAMETERS_NOT_AFFECTING_BASE_RESPONSE +
|
139
|
+
SIDELOAD_PARAMETERS).include?(p)
|
140
|
+
end
|
119
141
|
end
|
120
142
|
|
121
143
|
# override enumerable setup because we don't have
|
@@ -22,7 +22,7 @@ module Ecfr
|
|
22
22
|
perform(
|
23
23
|
:get,
|
24
24
|
structure_path(date, title_number, format),
|
25
|
-
params: options.except(:section, :appendix),
|
25
|
+
params: options.except(:section, :appendix).compact,
|
26
26
|
perform_options: {
|
27
27
|
init_data: {format: format},
|
28
28
|
parse_response: false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecfr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peregrinator
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|