dry-struct 1.7.1 → 1.8.1
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/CHANGELOG.md +124 -79
- data/LICENSE +1 -1
- data/README.md +8 -13
- data/dry-struct.gemspec +21 -15
- data/lib/dry/struct/class_interface.rb +6 -6
- data/lib/dry/struct/extensions/pretty_print.rb +1 -1
- data/lib/dry/struct/extensions/super_diff.rb +10 -0
- data/lib/dry/struct/extensions.rb +4 -0
- data/lib/dry/struct/hashify.rb +3 -3
- data/lib/dry/struct/version.rb +1 -1
- data/lib/dry/struct.rb +2 -2
- metadata +74 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b3949661d29cee88a8d29876846e0f6dd4e092f2f65a43307cfaa38814bf8f8b
|
|
4
|
+
data.tar.gz: ec23916ce98b47fecd001b958620e190fed5688a929b002f4cc048620a3df999
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5458cb033a707cce2d4058b71ed81ec791d3ecfe98b4c8f9520b9297453c31df7fd2f658b1083230288761279053db0b2fd5db3481f8fa450ff1a2d8a29e6783
|
|
7
|
+
data.tar.gz: 449f59b1cb3954d815c8ba7191e148e05ac8d594cc89f56e7673bcca9922e7ab5cdc447e6a591a3154993ea81298cf0ec3d9c7a330c5bd1979395f96118d97a1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,90 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
### Deprecated
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
5
17
|
|
|
6
18
|
### Fixed
|
|
7
19
|
|
|
8
|
-
|
|
20
|
+
### Security
|
|
21
|
+
|
|
22
|
+
[Unreleased]: https://github.com/dry-rb/dry-struct/compare/v1.8.1...main
|
|
23
|
+
|
|
24
|
+
## [1.8.1] - 2026-03-03
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Performance improvements for building a hash from `Dry::Struct` when it contains nested structs. (@katafrakt in #202, identified by @rpeng in #200)
|
|
29
|
+
|
|
30
|
+
[1.8.1]: https://github.com/dry-rb/dry-struct/compare/v1.8.0...v1.8.1
|
|
31
|
+
|
|
32
|
+
## [1.8.0] - 2025-03-09
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Added super_diff extension for improved struct diffing in RSpec tests (@flash-gordon in #197)
|
|
9
37
|
|
|
38
|
+
Add this to your Gemfile:
|
|
39
|
+
```ruby
|
|
40
|
+
gem 'super_diff', group: :test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then activate the extension in your spec_helper:
|
|
44
|
+
```ruby
|
|
45
|
+
Dry::Struct.load_extensions(:super_diff)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Now this
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
expected: #<Test::User name="Jane" age=22>
|
|
52
|
+
got: #<Test::User name="Jane" age=21>
|
|
53
|
+
|
|
54
|
+
(compared using eql?)
|
|
10
55
|
|
|
11
|
-
|
|
56
|
+
Diff:
|
|
57
|
+
@@ -1 +1 @@
|
|
58
|
+
-#<Test::User name="Jane" age=22>
|
|
59
|
+
+#<Test::User name="Jane" age=21>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
will become this:
|
|
12
63
|
|
|
13
|
-
|
|
64
|
+
```ruby
|
|
65
|
+
expected: #<Test::User name: "Jane", age: 22>
|
|
66
|
+
got: #<Test::User name: "Jane", age: 21>
|
|
14
67
|
|
|
68
|
+
(compared using eql?)
|
|
69
|
+
|
|
70
|
+
#<Test::User {
|
|
71
|
+
name: "Jane",
|
|
72
|
+
- age: 22
|
|
73
|
+
+ age: 21
|
|
74
|
+
}>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
[1.8.0]: https://github.com/dry-rb/dry-struct/compare/v1.7.1...v1.8.0
|
|
78
|
+
|
|
79
|
+
## [1.7.1] - 2025-01-31
|
|
80
|
+
|
|
81
|
+
### Fixed
|
|
82
|
+
|
|
83
|
+
- Syntax errors on 3.3.0 (@flash-gordon, see https://github.com/dry-rb/dry-types/issues/478)
|
|
84
|
+
|
|
85
|
+
[1.7.1]: https://github.com/dry-rb/dry-struct/compare/v1.7.0...v1.7.1
|
|
86
|
+
|
|
87
|
+
## [1.7.0] - 2025-01-06
|
|
15
88
|
|
|
16
89
|
### Fixed
|
|
17
90
|
|
|
@@ -25,48 +98,41 @@
|
|
|
25
98
|
- `Dry::Struct::Error` is now a subclass of `Dry::Types::CoercionError` (in #193) (@flash-gordon)
|
|
26
99
|
- `Dry::Struct#[]` now returns `nil` if an optional attribute is not set. This is consistent with calling accessor methods for optional attributes. (issue #171 via #194) (@ivleonov + @flash-gordon)
|
|
27
100
|
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
## 1.6.0 2022-11-04
|
|
101
|
+
[1.7.0]: https://github.com/dry-rb/dry-struct/compare/v1.6.0...v1.7.0
|
|
31
102
|
|
|
103
|
+
## [1.6.0] - 2022-11-04
|
|
32
104
|
|
|
33
105
|
### Changed
|
|
34
106
|
|
|
35
107
|
- This version uses dry-core 1.0 (@flash-gordon + @solnic)
|
|
36
108
|
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
## 1.5.2 2022-10-19
|
|
109
|
+
[1.6.0]: https://github.com/dry-rb/dry-struct/compare/v1.5.2...v1.6.0
|
|
40
110
|
|
|
111
|
+
## [1.5.2] - 2022-10-19
|
|
41
112
|
|
|
42
113
|
### Fixed
|
|
43
114
|
|
|
44
115
|
- Coercion failures keep the original error instead of just having a string (@flash-gordon + @newx)
|
|
45
116
|
|
|
117
|
+
[1.5.2]: https://github.com/dry-rb/dry-struct/compare/v1.5.1...v1.5.2
|
|
46
118
|
|
|
47
|
-
[
|
|
48
|
-
|
|
49
|
-
## 1.5.1 2022-10-17
|
|
50
|
-
|
|
119
|
+
## [1.5.1] - 2022-10-17
|
|
51
120
|
|
|
52
121
|
### Fixed
|
|
53
122
|
|
|
54
123
|
- Fixed issues with auto-loading `Extensions` module (issue #183 fixed via #184) (@solnic)
|
|
55
124
|
|
|
125
|
+
[1.5.1]: https://github.com/dry-rb/dry-struct/compare/v1.5.0...v1.5.1
|
|
56
126
|
|
|
57
|
-
[
|
|
58
|
-
|
|
59
|
-
## 1.5.0 2022-10-15
|
|
60
|
-
|
|
127
|
+
## [1.5.0] - 2022-10-15
|
|
61
128
|
|
|
62
129
|
### Changed
|
|
63
130
|
|
|
64
131
|
- Use zeitwerk for auto-loading (@flash-gordon)
|
|
65
132
|
|
|
66
|
-
[
|
|
67
|
-
|
|
68
|
-
## 1.4.0 2021-01-21
|
|
133
|
+
[1.5.0]: https://github.com/dry-rb/dry-struct/compare/v1.4.0...v1.5.0
|
|
69
134
|
|
|
135
|
+
## [1.4.0] - 2021-01-21
|
|
70
136
|
|
|
71
137
|
### Added
|
|
72
138
|
|
|
@@ -83,11 +149,9 @@
|
|
|
83
149
|
User.new(name: "John", address: nil) # => #<User name="John" address=nil>
|
|
84
150
|
```
|
|
85
151
|
|
|
152
|
+
[1.4.0]: https://github.com/dry-rb/dry-struct/compare/v1.3.0...v1.4.0
|
|
86
153
|
|
|
87
|
-
[
|
|
88
|
-
|
|
89
|
-
## 1.3.0 2020-02-10
|
|
90
|
-
|
|
154
|
+
## [1.3.0] - 2020-02-10
|
|
91
155
|
|
|
92
156
|
### Added
|
|
93
157
|
|
|
@@ -137,20 +201,18 @@
|
|
|
137
201
|
|
|
138
202
|
- [internal] metadata is now stored inside schema (@flash-gordon)
|
|
139
203
|
|
|
140
|
-
[
|
|
141
|
-
|
|
142
|
-
## 1.2.0 2019-12-20
|
|
204
|
+
[1.3.0]: https://github.com/dry-rb/dry-struct/compare/v1.2.0...v1.3.0
|
|
143
205
|
|
|
206
|
+
## [1.2.0] - 2019-12-20
|
|
144
207
|
|
|
145
208
|
### Changed
|
|
146
209
|
|
|
147
210
|
- `Dry::Struct::Value` is deprecated. `Dry::Struct` instances were never meant to be mutable, we have no support for this. The only difference between `Dry::Struct` and `Dry::Struct::Value` is that the latter is deeply frozen. Freezing objects slows the code down and gives you very little benefit in return. If you have a use case for `Value`, it won't be hard to roll your own solution using [ice_nine](https://github.com/dkubb/ice_nine) (flash-gordon)
|
|
148
211
|
- In the thread of the previous change, structs now use immutable equalizer. This means `Struct#hash` memoizes its value after the first invocation. Depending on the case, this may speed up your code significantly (flash-gordon)
|
|
149
212
|
|
|
150
|
-
[
|
|
151
|
-
|
|
152
|
-
## 1.1.1 2019-10-13
|
|
213
|
+
[1.2.0]: https://github.com/dry-rb/dry-struct/compare/v1.1.1...v1.2.0
|
|
153
214
|
|
|
215
|
+
## [1.1.1] - 2019-10-13
|
|
154
216
|
|
|
155
217
|
### Changed
|
|
156
218
|
|
|
@@ -171,20 +233,17 @@
|
|
|
171
233
|
|
|
172
234
|
See more examples in the [specs](https://github.com/dry-rb/dry-struct/blob/8112772eb08d22ff2cd3e6997514d79a9b124968/spec/dry/struct/pattern_matching_spec.rb).
|
|
173
235
|
|
|
174
|
-
[
|
|
175
|
-
|
|
176
|
-
## 1.1.0 2019-10-07
|
|
236
|
+
[1.1.1]: https://github.com/dry-rb/dry-struct/compare/v1.1.0...v1.1.1
|
|
177
237
|
|
|
238
|
+
## [1.1.0] - 2019-10-07
|
|
178
239
|
|
|
179
240
|
### Added
|
|
180
241
|
|
|
181
242
|
- Experimental support for pattern matching :tada: (flash-gordon)
|
|
182
243
|
|
|
244
|
+
[1.1.0]: https://github.com/dry-rb/dry-struct/compare/v1.0.0...v1.1.0
|
|
183
245
|
|
|
184
|
-
[
|
|
185
|
-
|
|
186
|
-
## 1.0.0 2019-04-23
|
|
187
|
-
|
|
246
|
+
## [1.0.0] - 2019-04-23
|
|
188
247
|
|
|
189
248
|
### Added
|
|
190
249
|
|
|
@@ -199,10 +258,9 @@
|
|
|
199
258
|
|
|
200
259
|
- `valid?` and `===` behave differently, `===` works the same way `Class#===` does and `valid?` checks if the value _can be_ coerced to the struct (flash-gordon)
|
|
201
260
|
|
|
202
|
-
[
|
|
203
|
-
|
|
204
|
-
## 0.7.0 2019-03-22
|
|
261
|
+
[1.0.0]: https://github.com/dry-rb/dry-struct/compare/v0.7.0...v1.0.0
|
|
205
262
|
|
|
263
|
+
## [0.7.0] - 2019-03-22
|
|
206
264
|
|
|
207
265
|
### Changed
|
|
208
266
|
|
|
@@ -229,10 +287,9 @@
|
|
|
229
287
|
- `Dry::Stuct#new` is now more efficient for partial updates (flash-gordon)
|
|
230
288
|
- Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
|
|
231
289
|
|
|
232
|
-
[
|
|
233
|
-
|
|
234
|
-
## 0.6.0 2018-10-24
|
|
290
|
+
[0.7.0]: https://github.com/dry-rb/dry-struct/compare/v0.6.0...v0.7.0
|
|
235
291
|
|
|
292
|
+
## [0.6.0] - 2018-10-24
|
|
236
293
|
|
|
237
294
|
### Added
|
|
238
295
|
|
|
@@ -254,10 +311,9 @@
|
|
|
254
311
|
|
|
255
312
|
- [BREAKING] `Struct.attribute?` in the old sense is deprecated, use `has_attribute?` as a replacement
|
|
256
313
|
|
|
257
|
-
[
|
|
258
|
-
|
|
259
|
-
## 0.5.1 2018-08-11
|
|
314
|
+
[0.6.0]: https://github.com/dry-rb/dry-struct/compare/v0.5.1...v0.6.0
|
|
260
315
|
|
|
316
|
+
## [0.5.1] - 2018-08-11
|
|
261
317
|
|
|
262
318
|
### Added
|
|
263
319
|
|
|
@@ -275,11 +331,9 @@
|
|
|
275
331
|
|
|
276
332
|
- Constant resolution is now restricted to the current module when structs are automatically defined using the block syntax. This shouldn't break any existing code (piktur)
|
|
277
333
|
|
|
334
|
+
[0.5.1]: https://github.com/dry-rb/dry-struct/compare/v0.5.0...v0.5.1
|
|
278
335
|
|
|
279
|
-
[
|
|
280
|
-
|
|
281
|
-
## 0.5.0 2018-05-03
|
|
282
|
-
|
|
336
|
+
## [0.5.0] - 2018-05-03
|
|
283
337
|
|
|
284
338
|
### Added
|
|
285
339
|
|
|
@@ -336,11 +390,9 @@
|
|
|
336
390
|
- Adding a new attribute invalidates `attribute_names` (flash-gordon)
|
|
337
391
|
- Struct classes track subclasses and define attributes in them, now it doesn't matter whether you define attributes first and _then_ subclass or vice versa. Note this can lead to memory leaks in Rails environment when struct classes are reloaded (flash-gordon)
|
|
338
392
|
|
|
393
|
+
[0.5.0]: https://github.com/dry-rb/dry-struct/compare/v0.4.0...v0.5.0
|
|
339
394
|
|
|
340
|
-
[
|
|
341
|
-
|
|
342
|
-
## 0.4.0 2017-11-04
|
|
343
|
-
|
|
395
|
+
## [0.4.0] - 2017-11-04
|
|
344
396
|
|
|
345
397
|
### Fixed
|
|
346
398
|
|
|
@@ -352,10 +404,9 @@
|
|
|
352
404
|
- `Struct#new` uses raw attributes instead of method calls, this makes the behavior consistent with the change above (flash-gordon)
|
|
353
405
|
- `constructor_type` now actively rejects `:weak` and `:symbolized` values (GustavoCaso)
|
|
354
406
|
|
|
355
|
-
[
|
|
356
|
-
|
|
357
|
-
## 0.3.1 2017-06-30
|
|
407
|
+
[0.4.0]: https://github.com/dry-rb/dry-struct/compare/v0.3.1...v0.4.0
|
|
358
408
|
|
|
409
|
+
## [0.3.1] - 2017-06-30
|
|
359
410
|
|
|
360
411
|
### Added
|
|
361
412
|
|
|
@@ -363,11 +414,9 @@
|
|
|
363
414
|
- `Struct.attribute?` and `Struct.attribute_names` for introspecting struct attributes (flash-gordon)
|
|
364
415
|
- `Struct#__new__` is a safe-to-use-in-gems alias for `Struct#new` (flash-gordon)
|
|
365
416
|
|
|
417
|
+
[0.3.1]: https://github.com/dry-rb/dry-struct/compare/v0.3.0...v0.3.1
|
|
366
418
|
|
|
367
|
-
[
|
|
368
|
-
|
|
369
|
-
## 0.3.0 2017-05-05
|
|
370
|
-
|
|
419
|
+
## [0.3.0] - 2017-05-05
|
|
371
420
|
|
|
372
421
|
### Added
|
|
373
422
|
|
|
@@ -382,39 +431,33 @@
|
|
|
382
431
|
|
|
383
432
|
- `.new` without arguments doesn't use nil as an input for non-default types anymore (flash-gordon)
|
|
384
433
|
|
|
385
|
-
[
|
|
386
|
-
|
|
387
|
-
## 0.2.1 2017-02-27
|
|
434
|
+
[0.3.0]: https://github.com/dry-rb/dry-struct/compare/v0.2.1...v0.3.0
|
|
388
435
|
|
|
436
|
+
## [0.2.1] - 2017-02-27
|
|
389
437
|
|
|
390
438
|
### Fixed
|
|
391
439
|
|
|
392
440
|
- Fixed `Dry::Struct::Value` which appeared to be broken in the last release (flash-gordon)
|
|
393
441
|
|
|
442
|
+
[0.2.1]: https://github.com/dry-rb/dry-struct/compare/v0.2.0...v0.2.1
|
|
394
443
|
|
|
395
|
-
[
|
|
396
|
-
|
|
397
|
-
## 0.2.0 2016-02-26
|
|
398
|
-
|
|
444
|
+
## [0.2.0] - 2016-02-26
|
|
399
445
|
|
|
400
446
|
### Changed
|
|
401
447
|
|
|
402
448
|
- Struct attributes can be overridden in a subclass (flash-gordon)
|
|
403
449
|
|
|
404
|
-
[
|
|
405
|
-
|
|
406
|
-
## 0.1.1 2016-11-13
|
|
450
|
+
[0.2.0]: https://github.com/dry-rb/dry-struct/compare/v0.1.1...v0.2.0
|
|
407
451
|
|
|
452
|
+
## [0.1.1] - 2016-11-13
|
|
408
453
|
|
|
409
454
|
### Fixed
|
|
410
455
|
|
|
411
456
|
- Make `Dry::Struct` act as a constrained type. This fixes the behavior of sum types containing structs (flash-gordon)
|
|
412
457
|
|
|
458
|
+
[0.1.1]: https://github.com/dry-rb/dry-struct/compare/v0.1.0...v0.1.1
|
|
413
459
|
|
|
414
|
-
[
|
|
415
|
-
|
|
416
|
-
## 0.1.0 2016-09-21
|
|
417
|
-
|
|
460
|
+
## [0.1.0] - 2016-09-21
|
|
418
461
|
|
|
419
462
|
### Added
|
|
420
463
|
|
|
@@ -426,8 +469,10 @@
|
|
|
426
469
|
- [BREAKING] `:strict` now raises on unexpected keys (backus)
|
|
427
470
|
- Structs no longer auto-register themselves in the types container as they implement `Type` interface and we don't have to wrap them in `Type::Definition` (flash-gordon)
|
|
428
471
|
|
|
429
|
-
[
|
|
472
|
+
[0.1.0]: https://github.com/dry-rb/dry-struct/compare/v0.0.1...v0.1.0
|
|
430
473
|
|
|
431
|
-
## 0.0.1 2016-07-17
|
|
474
|
+
## [0.0.1] - 2016-07-17
|
|
432
475
|
|
|
433
476
|
Initial release of code imported from dry-types
|
|
477
|
+
|
|
478
|
+
[0.0.1]: https://github.com/dry-rb/dry-struct/releases/tag/v0.0.1
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
<!---
|
|
2
|
-
|
|
1
|
+
<!--- This file is synced from hanakai-rb/repo-sync -->
|
|
2
|
+
|
|
3
|
+
[rubygem]: https://rubygems.org/gems/dry-struct
|
|
3
4
|
[actions]: https://github.com/dry-rb/dry-struct/actions
|
|
4
5
|
|
|
5
|
-
# dry-struct [][
|
|
6
|
+
# dry-struct [][rubygem] [][actions]
|
|
6
7
|
|
|
7
8
|
## Links
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Supported Ruby versions
|
|
14
|
-
|
|
15
|
-
This library officially supports the following Ruby versions:
|
|
16
|
-
|
|
17
|
-
* MRI `>= 3.1`
|
|
18
|
-
* jruby `>= 9.4` (not tested on CI)
|
|
10
|
+
- [User documentation](https://dry-rb.org/gems/dry-struct)
|
|
11
|
+
- [API documentation](http://rubydoc.info/gems/dry-struct)
|
|
12
|
+
- [Forum](https://discourse.dry-rb.org)
|
|
19
13
|
|
|
20
14
|
## License
|
|
21
15
|
|
|
22
16
|
See `LICENSE` file.
|
|
17
|
+
|
data/dry-struct.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
|
|
4
4
|
|
|
5
5
|
lib = File.expand_path("lib", __dir__)
|
|
6
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
@@ -8,8 +8,8 @@ require "dry/struct/version"
|
|
|
8
8
|
|
|
9
9
|
Gem::Specification.new do |spec|
|
|
10
10
|
spec.name = "dry-struct"
|
|
11
|
-
spec.authors = ["
|
|
12
|
-
spec.email = ["
|
|
11
|
+
spec.authors = ["Hanakai team"]
|
|
12
|
+
spec.email = ["info@hanakai.org"]
|
|
13
13
|
spec.license = "MIT"
|
|
14
14
|
spec.version = Dry::Struct::VERSION.dup
|
|
15
15
|
|
|
@@ -17,21 +17,27 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.description = spec.summary
|
|
18
18
|
spec.homepage = "https://dry-rb.org/gems/dry-struct"
|
|
19
19
|
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-struct.gemspec", "lib/**/*"]
|
|
20
|
-
spec.bindir = "
|
|
21
|
-
spec.executables = []
|
|
20
|
+
spec.bindir = "exe"
|
|
21
|
+
spec.executables = Dir["exe/*"].map { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
23
|
|
|
24
|
-
spec.
|
|
25
|
-
|
|
26
|
-
spec.metadata["
|
|
27
|
-
spec.metadata["
|
|
28
|
-
spec.metadata["
|
|
24
|
+
spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
|
|
25
|
+
|
|
26
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
27
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-struct/blob/main/CHANGELOG.md"
|
|
28
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-struct"
|
|
29
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-struct/issues"
|
|
30
|
+
spec.metadata["funding_uri"] = "https://github.com/sponsors/hanami"
|
|
29
31
|
|
|
30
32
|
spec.required_ruby_version = ">= 3.1.0"
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
spec.
|
|
34
|
-
spec.
|
|
35
|
-
spec.
|
|
36
|
-
spec.
|
|
34
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
|
35
|
+
spec.add_runtime_dependency "dry-core", "~> 1.1"
|
|
36
|
+
spec.add_runtime_dependency "dry-types", "~> 1.8", ">= 1.8.2"
|
|
37
|
+
spec.add_runtime_dependency "ice_nine", "~> 0.11"
|
|
38
|
+
spec.add_development_dependency "bundler"
|
|
39
|
+
spec.add_development_dependency "rake"
|
|
40
|
+
spec.add_development_dependency "rspec"
|
|
41
|
+
spec.add_development_dependency "yard"
|
|
37
42
|
end
|
|
43
|
+
|
|
@@ -5,7 +5,7 @@ require "weakref"
|
|
|
5
5
|
module Dry
|
|
6
6
|
class Struct
|
|
7
7
|
# Class-level interface of {Struct} and {Value}
|
|
8
|
-
module ClassInterface
|
|
8
|
+
module ClassInterface
|
|
9
9
|
include Core::ClassAttributes
|
|
10
10
|
|
|
11
11
|
include Types::Type
|
|
@@ -236,7 +236,7 @@ module Dry
|
|
|
236
236
|
|
|
237
237
|
# @param [Hash{Symbol => Object},Dry::Struct] attributes
|
|
238
238
|
# @raise [Struct::Error] if the given attributes don't conform {#schema}
|
|
239
|
-
def new(attributes = default_attributes, safe = false, &)
|
|
239
|
+
def new(attributes = default_attributes, safe = false, &)
|
|
240
240
|
if attributes.is_a?(Struct)
|
|
241
241
|
if equal?(attributes.class)
|
|
242
242
|
attributes
|
|
@@ -253,8 +253,8 @@ module Dry
|
|
|
253
253
|
else
|
|
254
254
|
load(schema.call_unsafe(attributes))
|
|
255
255
|
end
|
|
256
|
-
rescue Types::CoercionError =>
|
|
257
|
-
raise Error, "[#{self}.new] #{
|
|
256
|
+
rescue Types::CoercionError => exception
|
|
257
|
+
raise Error, "[#{self}.new] #{exception}", exception.backtrace
|
|
258
258
|
end
|
|
259
259
|
|
|
260
260
|
# @api private
|
|
@@ -295,8 +295,8 @@ module Dry
|
|
|
295
295
|
# @return [Dry::Types::Result]
|
|
296
296
|
def try(input)
|
|
297
297
|
success(self[input])
|
|
298
|
-
rescue Error =>
|
|
299
|
-
failure_result = failure(input,
|
|
298
|
+
rescue Error => exception
|
|
299
|
+
failure_result = failure(input, exception)
|
|
300
300
|
block_given? ? yield(failure_result) : failure_result
|
|
301
301
|
end
|
|
302
302
|
|
data/lib/dry/struct/hashify.rb
CHANGED
|
@@ -5,11 +5,11 @@ module Dry
|
|
|
5
5
|
# Helper for {Struct#to_hash} implementation
|
|
6
6
|
module Hashify
|
|
7
7
|
# Converts value to hash recursively
|
|
8
|
-
# @param [#to_hash, #
|
|
8
|
+
# @param [#to_hash, #to_ary, Object] value
|
|
9
9
|
# @return [Hash, Array]
|
|
10
10
|
def self.[](value)
|
|
11
|
-
if value.is_a?(Struct)
|
|
12
|
-
value.to_h
|
|
11
|
+
if value.is_a?(::Dry::Struct)
|
|
12
|
+
value.to_h
|
|
13
13
|
elsif value.respond_to?(:to_hash)
|
|
14
14
|
value.to_hash.transform_values { self[_1] }
|
|
15
15
|
elsif value.respond_to?(:to_ary)
|
data/lib/dry/struct/version.rb
CHANGED
data/lib/dry/struct.rb
CHANGED
|
@@ -206,8 +206,8 @@ module Dry
|
|
|
206
206
|
resolve_defaults: false
|
|
207
207
|
)
|
|
208
208
|
self.class.load(__attributes__.merge(new_attributes))
|
|
209
|
-
rescue Types::SchemaError, Types::MissingKeyError, Types::UnknownKeysError =>
|
|
210
|
-
raise Error, "[#{self}.new] #{
|
|
209
|
+
rescue Types::SchemaError, Types::MissingKeyError, Types::UnknownKeysError => exception
|
|
210
|
+
raise Error, "[#{self}.new] #{exception}"
|
|
211
211
|
end
|
|
212
212
|
alias_method :__new__, :new
|
|
213
213
|
|
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dry-struct
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
bindir: bin
|
|
7
|
+
- Hanakai team
|
|
8
|
+
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: zeitwerk
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.6'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.6'
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: dry-core
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,25 +72,70 @@ dependencies:
|
|
|
59
72
|
- !ruby/object:Gem::Version
|
|
60
73
|
version: '0.11'
|
|
61
74
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name:
|
|
75
|
+
name: bundler
|
|
63
76
|
requirement: !ruby/object:Gem::Requirement
|
|
64
77
|
requirements:
|
|
65
|
-
- - "
|
|
78
|
+
- - ">="
|
|
66
79
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
68
|
-
type: :
|
|
80
|
+
version: '0'
|
|
81
|
+
type: :development
|
|
69
82
|
prerelease: false
|
|
70
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
84
|
requirements:
|
|
72
|
-
- - "
|
|
85
|
+
- - ">="
|
|
73
86
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
87
|
+
version: '0'
|
|
88
|
+
- !ruby/object:Gem::Dependency
|
|
89
|
+
name: rake
|
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
type: :development
|
|
96
|
+
prerelease: false
|
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: rspec
|
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
109
|
+
type: :development
|
|
110
|
+
prerelease: false
|
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
116
|
+
- !ruby/object:Gem::Dependency
|
|
117
|
+
name: yard
|
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0'
|
|
123
|
+
type: :development
|
|
124
|
+
prerelease: false
|
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
75
130
|
description: Typed structs and value objects
|
|
76
131
|
email:
|
|
77
|
-
-
|
|
132
|
+
- info@hanakai.org
|
|
78
133
|
executables: []
|
|
79
134
|
extensions: []
|
|
80
|
-
extra_rdoc_files:
|
|
135
|
+
extra_rdoc_files:
|
|
136
|
+
- CHANGELOG.md
|
|
137
|
+
- LICENSE
|
|
138
|
+
- README.md
|
|
81
139
|
files:
|
|
82
140
|
- CHANGELOG.md
|
|
83
141
|
- LICENSE
|
|
@@ -91,6 +149,7 @@ files:
|
|
|
91
149
|
- lib/dry/struct/errors.rb
|
|
92
150
|
- lib/dry/struct/extensions.rb
|
|
93
151
|
- lib/dry/struct/extensions/pretty_print.rb
|
|
152
|
+
- lib/dry/struct/extensions/super_diff.rb
|
|
94
153
|
- lib/dry/struct/hashify.rb
|
|
95
154
|
- lib/dry/struct/printer.rb
|
|
96
155
|
- lib/dry/struct/struct_builder.rb
|
|
@@ -105,8 +164,7 @@ metadata:
|
|
|
105
164
|
changelog_uri: https://github.com/dry-rb/dry-struct/blob/main/CHANGELOG.md
|
|
106
165
|
source_code_uri: https://github.com/dry-rb/dry-struct
|
|
107
166
|
bug_tracker_uri: https://github.com/dry-rb/dry-struct/issues
|
|
108
|
-
|
|
109
|
-
post_install_message:
|
|
167
|
+
funding_uri: https://github.com/sponsors/hanami
|
|
110
168
|
rdoc_options: []
|
|
111
169
|
require_paths:
|
|
112
170
|
- lib
|
|
@@ -121,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
121
179
|
- !ruby/object:Gem::Version
|
|
122
180
|
version: '0'
|
|
123
181
|
requirements: []
|
|
124
|
-
rubygems_version: 3.
|
|
125
|
-
signing_key:
|
|
182
|
+
rubygems_version: 3.6.9
|
|
126
183
|
specification_version: 4
|
|
127
184
|
summary: Typed structs and value objects
|
|
128
185
|
test_files: []
|