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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +6 -0
- data/lib/data.rb +12 -1
- data/lib/polyfill/data/version.rb +1 -1
- data/test/test_data.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20b2218a1dd7298ead1e7bd8f08502558a2828f7aef9a5be33424084bd2d1c9b
|
4
|
+
data.tar.gz: fc1c0a53cab242883ffcae75f523a959e5a9b273c14f9e8fd334f5db78875802
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
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
|
-
|
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.
|
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-
|
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
|