internetdata 2.8.2 → 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: 7d3e5a062df6437136402c90240f234437b93f6ce85ea1ffb60503c7adbcce1c
4
- data.tar.gz: f3a9930a8eaecf8613154ae49cc4a8a85850b1e19b3077036ab46e4968657ea2
3
+ metadata.gz: 7011f0bcf3c4f2a044352231eecb9de8d1a3420ec329f9f73972ba29194ebfb6
4
+ data.tar.gz: 46203ec5afc610e1da52f18536fca3e614b518cbfa8f54ae5ccfa3af733c8df7
5
5
  SHA512:
6
- metadata.gz: 61735554381aca9b15635a4cd43205d46008c95eaadf704c547ca2f8af2157ca1b0bd1c21bfbe0c2f952f06ff3cc1256ef39d63db6a72e346bbf1f3685295263
7
- data.tar.gz: a8f9d87c87dff2c4b824e0d17f1e63a98e057e47abb24f8375c230d476a69fe9e5bf284a1882390f436700ddfff730b5849f5cede27602fd40439b8d78aa5f46
6
+ metadata.gz: a277a6265ba1da68fc66702c0c1990930a215699eaf67671b1b8f6e527e6cb3ae26f6fbab38fc63f65af7cd4acd0715d48a6b34537e9f6ab7daee41905eae359
7
+ data.tar.gz: eeaffa84a34a6bfa2574075c297ae24ea9dc20d651f3fb84b8a477966a3f90bbd7d93a6cbe75cdeee7f4dceb6662698456d1334e5db6e5dfa58aae4d0c069368
@@ -215,6 +215,14 @@ module InternetData
215
215
  'Download' => %i[dataset_id format outcome sample open bytes http_status apikey_id client_ip user_agent created],
216
216
  }.freeze
217
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
+
218
226
  private
219
227
 
220
228
  # True when `value` has the generated `type`, a model's members recursively;
@@ -226,7 +234,8 @@ module InternetData
226
234
 
227
235
  typed =
228
236
  case type
229
- 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)
230
239
  when 'Integer' then value.is_a?(Integer)
231
240
  when 'Float' then value.is_a?(Numeric)
232
241
  when 'Boolean' then [true, false].include?(value)
@@ -250,6 +259,15 @@ module InternetData
250
259
  raise TypeError, "#{where} is not a #{type}"
251
260
  end
252
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
+
253
271
  # A member absent or null reads as absent, unless the spec requires it and
254
272
  # does not make it nullable.
255
273
  def check_member!(model, attr, member, value, where)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InternetData
4
- VERSION = '2.8.2'
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.2
4
+ version: 2.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mslm Dev