polyfill-data 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 156f764bced601a2ebf8cc7a6ee095d63a4d3f813ee3e9fe7c3b273ce68f007f
4
- data.tar.gz: d7425307509c331ac61c33541da58effcbbb1f5b6ce675ede734b27c2acf0ed3
3
+ metadata.gz: 20b2218a1dd7298ead1e7bd8f08502558a2828f7aef9a5be33424084bd2d1c9b
4
+ data.tar.gz: fc1c0a53cab242883ffcae75f523a959e5a9b273c14f9e8fd334f5db78875802
5
5
  SHA512:
6
- metadata.gz: 76a56991f1759077af526ef30236fcde606cd7fdc4dd9b5264e6d3012ad02e5a27feafa2dcf6900a54cd47e25525ee221702e07f41b6178f5cbb3cb7c4c2abfc
7
- data.tar.gz: 995d6359685044724e2fda6a31e8dab8c73cbdee97dc49034ef7c45ee39a04a3a05ab7ec3046f78705e931316e2957a0992cbe3b3a36c1fd7d43794e89ee22ca
6
+ metadata.gz: 9291cd87f95c34b47e5a32f87bffa79f5eca7d0419c1fc741ee88ca3e3518a7435b63c827db569a2960b7fb3d516a408058db3a7fbde49f2dc1328d8dcc5109d
7
+ data.tar.gz: df56331c22ecc1ce85aaf5f2e743230b944f07298b1fdc248a337c3731628152f5fffc699d4eaa6ca3490767ff71ab23ea5cb98bbe9dd3f778fbe525c46e9807
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 1.0.3
9
+
10
+ ### Fixed
11
+
12
+ - `new` correctly raises ArugmentErrors with incorrect arguments on Data subclasses
13
+
8
14
  ## 1.0.2
9
15
 
10
16
  ### Fixed
data/lib/data.rb CHANGED
@@ -23,8 +23,8 @@ else
23
23
  klass.define_singleton_method(:members) { args.map{ _1.intern } }
24
24
 
25
25
  klass.define_singleton_method(:new) do |*new_args, **new_kwargs, &block|
26
-
27
26
  init_kwargs = if new_args.any?
27
+ raise ArgumentError, "unknown arguments #{new_args[members.size..].join(', ')}" if new_args.size > members.size
28
28
  Hash[members.take(new_args.size).zip(new_args)]
29
29
  else
30
30
  new_kwargs
@@ -55,6 +55,17 @@ else
55
55
  end
56
56
 
57
57
  def initialize(**kwargs)
58
+ kwargs_size = kwargs.size
59
+ members_size = members.size
60
+
61
+ if kwargs_size > members_size
62
+ extras = kwargs.reject{|k, _v| members.include?(k) }.keys
63
+ raise ArgumentError, "unknown arguments #{extras.join(', ')}"
64
+ elsif kwargs_size < members_size
65
+ missing = members.select {|k, _v| !kwargs.include?(k) }
66
+ raise ArgumentError, "missing arguments #{missing.map{ ":#{_1}" }.join(', ')}"
67
+ end
68
+
58
69
  @attributes = Hash[members.map {|m| [m,kwargs[m]] }]
59
70
  end
60
71
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Polyfill
4
4
  module Data
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.3"
6
6
  end
7
7
  end
data/test/test_data.rb CHANGED
@@ -86,7 +86,7 @@ class TestData < Minitest::Test
86
86
  super(foo: 1, bar: 2) # so we can experiment with passing wrong numbers of args
87
87
  end
88
88
  end
89
- # require 'debug'; debugger
89
+
90
90
  assert_equal([[], {foo: 1, bar: 2}], klass.new(foo: 1, bar: 2).passed)
91
91
 
92
92
  # Positional arguments are converted to keyword ones
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyfill-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
@@ -34,7 +34,7 @@ cert_chain:
34
34
  dxkiKqcX+yzo9RJLD9l/E1AWX125r1Fhiif4l6ehdl7Vllc3NQUOm1abdmHtCYjw
35
35
  dG3yPWBWzzN4ovoBRqsuTJbF1wjkCjl5ex5KhfYbeDc=
36
36
  -----END CERTIFICATE-----
37
- date: 2023-01-21 00:00:00.000000000 Z
37
+ date: 2023-01-22 00:00:00.000000000 Z
38
38
  dependencies: []
39
39
  description: Add the ruby 3.2 Data class to older rubies
40
40
  email:
metadata.gz.sig CHANGED
Binary file