internetdata 2.8.1 → 2.8.3

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: 0d5119e3e00cca75d9bfed96e29ea5e4e4b3f442c02af34ce83488dbd77dda7f
4
- data.tar.gz: df7252680ed2fc7cd21e8b0dc04971ec09dd64f3c2685bf01bbb38be67e2afa7
3
+ metadata.gz: 7011f0bcf3c4f2a044352231eecb9de8d1a3420ec329f9f73972ba29194ebfb6
4
+ data.tar.gz: 46203ec5afc610e1da52f18536fca3e614b518cbfa8f54ae5ccfa3af733c8df7
5
5
  SHA512:
6
- metadata.gz: 3802406b345983d01c71f1cb772373ab612756dc775fa75ac5700d536ef667f4804aa88e87a1232c883a10a14f6bc793b4da1d1d4b6dbaff04eb272404dfcd1d
7
- data.tar.gz: '0805d1cdbde1207112c95a6da3d4068d84375a81d17f967acaacb3fbc41361a0ae87891392658aedd8e840e72345172932c10d3f114d13446cb444b0d899d5f6'
6
+ metadata.gz: a277a6265ba1da68fc66702c0c1990930a215699eaf67671b1b8f6e527e6cb3ae26f6fbab38fc63f65af7cd4acd0715d48a6b34537e9f6ab7daee41905eae359
7
+ data.tar.gz: eeaffa84a34a6bfa2574075c297ae24ea9dc20d651f3fb84b8a477966a3f90bbd7d93a6cbe75cdeee7f4dceb6662698456d1334e5db6e5dfa58aae4d0c069368
@@ -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,17 +198,44 @@ 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
+
218
+ # RFC 3339's full-date, the spec's `date`, and its date-time, the spec's
219
+ # `date-time`, in the upper case the API sends. Anything else reached the
220
+ # generated reader's Date.parse or Time.parse, which read "monday" as this
221
+ # week's, "10:00" as today in the process's zone and 30 February as 2 March
222
+ # (2.8.2, measured 2026-10-20).
223
+ RFC3339_DATE = /\A(\d{4})-(\d{2})-(\d{2})\z/
224
+ RFC3339_DATE_TIME = /\A(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](\d{2}):(\d{2}))\z/
225
+
201
226
  private
202
227
 
203
228
  # True when `value` has the generated `type`, a model's members recursively;
204
- # raises TypeError naming where it does not. A null is left to the models'
205
- # own required-member checks.
229
+ # raises TypeError naming where it does not. No list entry or map value the
230
+ # spec describes may be null, and through 2.8.1 one came back as nil, or as 0
231
+ # in `size`.
206
232
  def check_type!(value, type, where)
207
- return true if value.nil?
233
+ raise TypeError, "#{where} is null" if value.nil?
208
234
 
209
235
  typed =
210
236
  case type
211
- when 'String', 'Date', 'Time' then value.is_a?(String)
237
+ when 'String' then value.is_a?(String)
238
+ when 'Date', 'Time' then value.is_a?(String) && date?(value, type)
212
239
  when 'Integer' then value.is_a?(Integer)
213
240
  when 'Float' then value.is_a?(Numeric)
214
241
  when 'Boolean' then [true, false].include?(value)
@@ -222,10 +249,7 @@ module InternetData
222
249
  else
223
250
  model = InternetData.const_get(type)
224
251
  if model.respond_to?(:openapi_types)
225
- value.is_a?(Hash) && model.openapi_types.all? do |attr, member|
226
- key = model.attribute_map[attr]
227
- check_type!(value[key], member.to_s, "#{where}.#{key}")
228
- end
252
+ value.is_a?(Hash) && model.openapi_types.all? { |attr, member| check_member!(model, attr, member, value, where) }
229
253
  else
230
254
  value.is_a?(String) # an enum
231
255
  end
@@ -234,5 +258,25 @@ module InternetData
234
258
 
235
259
  raise TypeError, "#{where} is not a #{type}"
236
260
  end
261
+
262
+ # A date in the form its type names, on a day and at a time that exist: an
263
+ # hour of 24 rolls over the way a missing day does.
264
+ def date?(value, type)
265
+ m = (type == 'Date' ? RFC3339_DATE : RFC3339_DATE_TIME).match(value)
266
+ return false unless m && Date.valid_date?(m[1].to_i, m[2].to_i, m[3].to_i)
267
+
268
+ type == 'Date' || (m[4].to_i < 24 && m[5].to_i < 60 && m[6].to_i < 60 && m[7].to_i < 24 && m[8].to_i < 60)
269
+ end
270
+
271
+ # A member absent or null reads as absent, unless the spec requires it and
272
+ # does not make it nullable.
273
+ def check_member!(model, attr, member, value, where)
274
+ key = model.attribute_map[attr]
275
+ return check_type!(value[key], member.to_s, "#{where}.#{key}") unless value[key].nil?
276
+ return true unless REQUIRED.fetch(model.name.split('::').last).include?(attr)
277
+ return true if model.openapi_nullable.include?(attr)
278
+
279
+ raise TypeError, "#{where}.#{key} is #{value.key?(key) ? 'null' : 'missing'}"
280
+ end
237
281
  end
238
282
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InternetData
4
- VERSION = '2.8.1'
4
+ VERSION = '2.8.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: internetdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.1
4
+ version: 2.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mslm Dev