internetdata 2.8.1 → 2.8.2
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/lib/internetdata/errors.rb +4 -2
- data/lib/internetdata/transport.rb +33 -7
- data/lib/internetdata/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d3e5a062df6437136402c90240f234437b93f6ce85ea1ffb60503c7adbcce1c
|
|
4
|
+
data.tar.gz: f3a9930a8eaecf8613154ae49cc4a8a85850b1e19b3077036ab46e4968657ea2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61735554381aca9b15635a4cd43205d46008c95eaadf704c547ca2f8af2157ca1b0bd1c21bfbe0c2f952f06ff3cc1256ef39d63db6a72e346bbf1f3685295263
|
|
7
|
+
data.tar.gz: a8f9d87c87dff2c4b824e0d17f1e63a98e057e47abb24f8375c230d476a69fe9e5bf284a1882390f436700ddfff730b5849f5cede27602fd40439b8d78aa5f46
|
data/lib/internetdata/errors.rb
CHANGED
|
@@ -100,9 +100,11 @@ module InternetData
|
|
|
100
100
|
return nil if value.empty?
|
|
101
101
|
return Integer(value, 10) if value.match?(/\A\d+\z/)
|
|
102
102
|
|
|
103
|
-
# The header also permits an HTTP date.
|
|
103
|
+
# The header also permits an HTTP date, naming a real day: `Time.httpdate`
|
|
104
|
+
# reads `31 Nov` as 1 December, and the day it names comes first in all
|
|
105
|
+
# three forms.
|
|
104
106
|
when_at = Time.httpdate(value) rescue nil
|
|
105
|
-
return nil if when_at.nil?
|
|
107
|
+
return nil if when_at.nil? || when_at.day != value[/\d+/].to_i
|
|
106
108
|
|
|
107
109
|
[0, (when_at - Time.now).ceil].max
|
|
108
110
|
end
|
|
@@ -198,13 +198,31 @@ module InternetData
|
|
|
198
198
|
|
|
199
199
|
private_class_method :transport_failure?, :parse_object, :oauth_refusal
|
|
200
200
|
|
|
201
|
+
# The members the spec requires of each answer a database call reads. One of
|
|
202
|
+
# them that is not nullable must be there and not null: the generated reader
|
|
203
|
+
# skips the writer of a list or map member that is not one, so `"versions":
|
|
204
|
+
# null` came back as a family with no versions (2.8.1, measured 2026-10-19).
|
|
205
|
+
# test/database_test.rb holds this to spec/openapi.yaml.
|
|
206
|
+
REQUIRED = {
|
|
207
|
+
'DatabaseList' => %i[databases],
|
|
208
|
+
'Database' => %i[base name summary standing open license_type starts expires renews_at notice_due_at versions],
|
|
209
|
+
'DatabaseVersion' => %i[id version summary formats],
|
|
210
|
+
'DatabaseMetadata' => %i[id updated entries schema size],
|
|
211
|
+
'DatabaseMetadataColumn' => %i[name type],
|
|
212
|
+
'DatabaseChecksumsResponse' => %i[id format checksums],
|
|
213
|
+
'DbChecksums' => %i[md5 sha1 sha256 sha512],
|
|
214
|
+
'DownloadList' => %i[downloads],
|
|
215
|
+
'Download' => %i[dataset_id format outcome sample open bytes http_status apikey_id client_ip user_agent created],
|
|
216
|
+
}.freeze
|
|
217
|
+
|
|
201
218
|
private
|
|
202
219
|
|
|
203
220
|
# True when `value` has the generated `type`, a model's members recursively;
|
|
204
|
-
# raises TypeError naming where it does not.
|
|
205
|
-
#
|
|
221
|
+
# raises TypeError naming where it does not. No list entry or map value the
|
|
222
|
+
# spec describes may be null, and through 2.8.1 one came back as nil, or as 0
|
|
223
|
+
# in `size`.
|
|
206
224
|
def check_type!(value, type, where)
|
|
207
|
-
|
|
225
|
+
raise TypeError, "#{where} is null" if value.nil?
|
|
208
226
|
|
|
209
227
|
typed =
|
|
210
228
|
case type
|
|
@@ -222,10 +240,7 @@ module InternetData
|
|
|
222
240
|
else
|
|
223
241
|
model = InternetData.const_get(type)
|
|
224
242
|
if model.respond_to?(:openapi_types)
|
|
225
|
-
value.is_a?(Hash) && model.openapi_types.all?
|
|
226
|
-
key = model.attribute_map[attr]
|
|
227
|
-
check_type!(value[key], member.to_s, "#{where}.#{key}")
|
|
228
|
-
end
|
|
243
|
+
value.is_a?(Hash) && model.openapi_types.all? { |attr, member| check_member!(model, attr, member, value, where) }
|
|
229
244
|
else
|
|
230
245
|
value.is_a?(String) # an enum
|
|
231
246
|
end
|
|
@@ -234,5 +249,16 @@ module InternetData
|
|
|
234
249
|
|
|
235
250
|
raise TypeError, "#{where} is not a #{type}"
|
|
236
251
|
end
|
|
252
|
+
|
|
253
|
+
# A member absent or null reads as absent, unless the spec requires it and
|
|
254
|
+
# does not make it nullable.
|
|
255
|
+
def check_member!(model, attr, member, value, where)
|
|
256
|
+
key = model.attribute_map[attr]
|
|
257
|
+
return check_type!(value[key], member.to_s, "#{where}.#{key}") unless value[key].nil?
|
|
258
|
+
return true unless REQUIRED.fetch(model.name.split('::').last).include?(attr)
|
|
259
|
+
return true if model.openapi_nullable.include?(attr)
|
|
260
|
+
|
|
261
|
+
raise TypeError, "#{where}.#{key} is #{value.key?(key) ? 'null' : 'missing'}"
|
|
262
|
+
end
|
|
237
263
|
end
|
|
238
264
|
end
|
data/lib/internetdata/version.rb
CHANGED