dry-struct 1.0.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +246 -82
- data/LICENSE +17 -17
- data/README.md +18 -13
- data/dry-struct.gemspec +35 -35
- data/lib/dry/struct/class_interface.rb +139 -77
- data/lib/dry/struct/compiler.rb +19 -0
- data/lib/dry/struct/constructor.rb +4 -24
- data/lib/dry/struct/errors.rb +13 -3
- data/lib/dry/struct/extensions/pretty_print.rb +8 -6
- data/lib/dry/struct/extensions.rb +3 -1
- data/lib/dry/struct/hashify.rb +6 -6
- data/lib/dry/struct/printer.rb +6 -1
- data/lib/dry/struct/struct_builder.rb +46 -24
- data/lib/dry/struct/sum.rb +5 -5
- data/lib/dry/struct/value.rb +12 -4
- data/lib/dry/struct/version.rb +3 -1
- data/lib/dry/struct.rb +70 -35
- data/lib/dry-struct.rb +3 -1
- metadata +48 -54
- data/.gitignore +0 -12
- data/.rspec +0 -2
- data/.travis.yml +0 -29
- data/.yardopts +0 -4
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -26
- data/Rakefile +0 -10
- data/benchmarks/basic.rb +0 -57
- data/benchmarks/constrained.rb +0 -37
- data/benchmarks/profile_instantiation.rb +0 -19
- data/benchmarks/setup.rb +0 -11
- data/bin/console +0 -12
- data/bin/setup +0 -7
- data/log/.gitkeep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3309e15a4b8084a8ddb210a4d62e51e063a54f0aec56f41398f41824bbfe687
|
4
|
+
data.tar.gz: 05de1a1085a1753cd22f6f42a459de2245a544fe6ab822dff2bae228fe91da45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16f8476d1362fa11871db6be02787e8b106795ca5d4a1ebeb1c796cc22abcd5ee0c0cf8f7985191a180dcfb38a1679535be4ff13003e0b08459072a2b236e288
|
7
|
+
data.tar.gz: e8973dbc9cc1fc0033751299ac366504c047cd996e9e9c5718ecad6e2d4bf2cdb734d46fd76f99c074a7982cb8cff6f9085a18725a01b21ea6e42475218f06e5
|
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,185 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
-
##
|
3
|
+
## 1.6.0 2022-11-04
|
4
4
|
|
5
|
-
* `valid?` and `===` behave differently, `===` works the same way `Class#===` does and `valid?` checks if the value _can be_ coerced to the struct (flash-gordon)
|
6
5
|
|
7
|
-
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- This version uses dry-core 1.0 (@flash-gordon + @solnic)
|
9
|
+
|
10
|
+
[Compare v1.5.2...v1.6.0](https://github.com/dry-rb/dry-struct/compare/v1.5.2...v1.6.0)
|
11
|
+
|
12
|
+
## 1.5.2 2022-10-19
|
13
|
+
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Coercion failures keep the original error instead of just having a string (@flash-gordon + @newx)
|
18
|
+
|
19
|
+
|
20
|
+
[Compare v1.5.1...v1.5.2](https://github.com/dry-rb/dry-struct/compare/v1.5.1...v1.5.2)
|
21
|
+
|
22
|
+
## 1.5.1 2022-10-17
|
23
|
+
|
24
|
+
|
25
|
+
### Fixed
|
26
|
+
|
27
|
+
- Fixed issues with auto-loading `Extensions` module (issue #183 fixed via #184) (@solnic)
|
28
|
+
|
29
|
+
|
30
|
+
[Compare v1.5.0...v1.5.1](https://github.com/dry-rb/dry-struct/compare/v1.5.0...v1.5.1)
|
31
|
+
|
32
|
+
## 1.5.0 2022-10-15
|
33
|
+
|
34
|
+
|
35
|
+
### Changed
|
36
|
+
|
37
|
+
- Use zeitwerk for auto-loading (@flash-gordon)
|
38
|
+
|
39
|
+
[Compare v1.4.0...v1.5.0](https://github.com/dry-rb/dry-struct/compare/v1.4.0...v1.5.0)
|
40
|
+
|
41
|
+
## 1.4.0 2021-01-21
|
42
|
+
|
43
|
+
|
44
|
+
### Added
|
45
|
+
|
46
|
+
- Support for wrapping constructors and fallbacks, see release notes for dry-types 1.5.0 (@flash-gordon)
|
47
|
+
- Improvements of the attribute DSL, now it's possible to use optional structs as a base class (@flash-gordon)
|
48
|
+
```ruby
|
49
|
+
class User < Dry::Struct
|
50
|
+
attribute :name, Types::String
|
51
|
+
attribute :address, Dry::Struct.optional do
|
52
|
+
attribute :city, Types::String
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
User.new(name: "John", address: nil) # => #<User name="John" address=nil>
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
[Compare v1.3.0...v1.4.0](https://github.com/dry-rb/dry-struct/compare/v1.3.0...v1.4.0)
|
61
|
+
|
62
|
+
## 1.3.0 2020-02-10
|
63
|
+
|
64
|
+
|
65
|
+
### Added
|
66
|
+
|
67
|
+
- Nested structures will reuse type and key transformations from the enclosing struct (@flash-gordon)
|
8
68
|
|
9
|
-
|
69
|
+
```ruby
|
70
|
+
class User < Dry::Struct
|
71
|
+
transform_keys(&:to_sym)
|
72
|
+
|
73
|
+
attribute :name, Types::String
|
74
|
+
attribute :address do
|
75
|
+
# this struct will inherit transform_keys(&:to_sym)
|
76
|
+
attribute :city, Types::String
|
77
|
+
end
|
78
|
+
|
79
|
+
# nested struct will _not_ transform keys because a parent
|
80
|
+
# struct is given
|
81
|
+
attribute :contacts, Dry::Struct do
|
82
|
+
attribute :email, Types::String
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
- `Dry::Struct::Constructor` finally acts like a fully-featured type (@flash-gordon)
|
87
|
+
- `Dry::Struct.abstract` declares a struct class as abstract. An abstract class is used as a default superclass for nested structs (@flash-gordon)
|
88
|
+
- `Dry::Struct.to_ast` and struct compiler (@flash-gordon)
|
89
|
+
- Struct composition with `Dry::Struct.attributes_from`. It's more flexible than inheritance (@waiting-for-dev + @flash-gordon)
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
class Address < Dry::Struct
|
93
|
+
attribute :city, Types::String
|
94
|
+
attribute :zipcode, Types::String
|
95
|
+
end
|
96
|
+
|
97
|
+
class Buyer < Dry::Struct
|
98
|
+
attribute :name, Types::String
|
99
|
+
attributes_from Address
|
100
|
+
end
|
101
|
+
|
102
|
+
class Seller < Dry::Struct
|
103
|
+
attribute :name, Types::String
|
104
|
+
attribute :email, Types::String
|
105
|
+
attributes_from Address
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
### Changed
|
110
|
+
|
111
|
+
- [internal] metadata is now stored inside schema (@flash-gordon)
|
112
|
+
|
113
|
+
[Compare v1.2.0...v1.3.0](https://github.com/dry-rb/dry-struct/compare/v1.2.0...v1.3.0)
|
114
|
+
|
115
|
+
## 1.2.0 2019-12-20
|
116
|
+
|
117
|
+
|
118
|
+
### Changed
|
119
|
+
|
120
|
+
- `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)
|
121
|
+
- 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)
|
122
|
+
|
123
|
+
[Compare v1.1.1...v1.2.0](https://github.com/dry-rb/dry-struct/compare/v1.1.1...v1.2.0)
|
124
|
+
|
125
|
+
## 1.1.1 2019-10-13
|
126
|
+
|
127
|
+
|
128
|
+
### Changed
|
129
|
+
|
130
|
+
- Pattern matching syntax is simplified with `deconstruct_keys` (k-tsj)
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
User = Dry.Struct(name: 'string', email: 'string')
|
134
|
+
|
135
|
+
user = User.new(name: 'John Doe', email: 'john@acme.org')
|
136
|
+
|
137
|
+
case user
|
138
|
+
in User(name: 'John Doe', email:)
|
139
|
+
puts email
|
140
|
+
else
|
141
|
+
puts 'Not John'
|
142
|
+
end
|
143
|
+
```
|
144
|
+
|
145
|
+
See more examples in the [specs](https://github.com/dry-rb/dry-struct/blob/8112772eb08d22ff2cd3e6997514d79a9b124968/spec/dry/struct/pattern_matching_spec.rb).
|
146
|
+
|
147
|
+
[Compare v1.1.0...v1.1.1](https://github.com/dry-rb/dry-struct/compare/v1.1.0...v1.1.1)
|
148
|
+
|
149
|
+
## 1.1.0 2019-10-07
|
150
|
+
|
151
|
+
|
152
|
+
### Added
|
153
|
+
|
154
|
+
- Experimental support for pattern matching :tada: (flash-gordon)
|
155
|
+
|
156
|
+
|
157
|
+
[Compare v1.0.0...v1.1.0](https://github.com/dry-rb/dry-struct/compare/v1.0.0...v1.1.0)
|
158
|
+
|
159
|
+
## 1.0.0 2019-04-23
|
160
|
+
|
161
|
+
|
162
|
+
### Added
|
163
|
+
|
164
|
+
- `Struct.call` now accepts an optional block that will be called on failed coercion. This behavior is consistent with dry-types 1.0. Note that `.new` doesn't take a block (flash-gordon)
|
10
165
|
```ruby
|
11
166
|
User = Dry::Struct(name: 'string')
|
12
167
|
User.(1) { :oh_no }
|
13
168
|
# => :oh_no
|
14
169
|
```
|
15
170
|
|
171
|
+
### Changed
|
172
|
+
|
173
|
+
- `valid?` and `===` behave differently, `===` works the same way `Class#===` does and `valid?` checks if the value _can be_ coerced to the struct (flash-gordon)
|
174
|
+
|
16
175
|
[Compare v0.7.0...v1.0.0](https://github.com/dry-rb/dry-struct/compare/v0.7.0...v1.0.0)
|
17
176
|
|
18
|
-
|
177
|
+
## 0.7.0 2019-03-22
|
19
178
|
|
20
|
-
## Changed
|
21
179
|
|
22
|
-
|
180
|
+
### Changed
|
181
|
+
|
182
|
+
- [BREAKING] `Struct.input` was renamed `Struct.schema`, hence `Struct.schema` returns an instance of `Dry::Types::Hash::Schema` rather than a `Hash`. Schemas are also implementing `Enumerable` but they iterate over key types.
|
23
183
|
New API:
|
24
184
|
```ruby
|
25
185
|
User.schema.each do |key|
|
@@ -31,7 +191,7 @@
|
|
31
191
|
```ruby
|
32
192
|
User.schema.key(:id) # => #<Dry::Types::Hash::Key ...>
|
33
193
|
```
|
34
|
-
|
194
|
+
- [BREAKING] `transform_types` now passes one argument to the block, an instance of the `Key` type. Combined with the new API from dry-types it simplifies declaring omittable keys:
|
35
195
|
```ruby
|
36
196
|
class StructWithOptionalKeys < Dry::Struct
|
37
197
|
transform_types { |key| key.required(false) }
|
@@ -39,20 +199,17 @@
|
|
39
199
|
transform_types(&:omittable)
|
40
200
|
end
|
41
201
|
```
|
42
|
-
|
43
|
-
|
202
|
+
- `Dry::Stuct#new` is now more efficient for partial updates (flash-gordon)
|
203
|
+
- Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
|
44
204
|
|
45
205
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-struct/compare/v0.6.0...v0.7.0)
|
46
206
|
|
47
|
-
|
48
|
-
|
49
|
-
## Changed
|
207
|
+
## 0.6.0 2018-10-24
|
50
208
|
|
51
|
-
* [BREAKING] `Struct.attribute?` in the old sense is deprecated, use `has_attribute?` as a replacement
|
52
209
|
|
53
|
-
|
210
|
+
### Added
|
54
211
|
|
55
|
-
|
212
|
+
- `Struct.attribute?` is an easy way to define omittable attributes (flash-gordon):
|
56
213
|
|
57
214
|
```ruby
|
58
215
|
class User < Dry::Struct
|
@@ -62,21 +219,22 @@
|
|
62
219
|
# User.new(name: 'John') # => #<User name="John">
|
63
220
|
```
|
64
221
|
|
65
|
-
|
222
|
+
### Fixed
|
66
223
|
|
67
|
-
|
224
|
+
- `Struct#to_h` recursively converts hash values to hashes, this was done to be consistent with current behavior for arrays (oeoeaio + ZimbiX)
|
68
225
|
|
69
|
-
|
226
|
+
### Changed
|
227
|
+
|
228
|
+
- [BREAKING] `Struct.attribute?` in the old sense is deprecated, use `has_attribute?` as a replacement
|
70
229
|
|
71
|
-
|
230
|
+
[Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-struct/compare/v0.5.1...v0.6.0)
|
72
231
|
|
73
|
-
##
|
232
|
+
## 0.5.1 2018-08-11
|
74
233
|
|
75
|
-
* 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)
|
76
234
|
|
77
|
-
|
235
|
+
### Added
|
78
236
|
|
79
|
-
|
237
|
+
- Pretty print extension (ojab)
|
80
238
|
```ruby
|
81
239
|
Dry::Struct.load_extensions(:pretty_print)
|
82
240
|
PP.pp(user)
|
@@ -86,20 +244,19 @@
|
|
86
244
|
address=#<Test::Address city="NYC", zipcode="123">>
|
87
245
|
```
|
88
246
|
|
89
|
-
|
247
|
+
### Fixed
|
248
|
+
|
249
|
+
- 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)
|
250
|
+
|
90
251
|
|
91
|
-
|
252
|
+
[Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-struct/compare/v0.5.0...v0.5.1)
|
92
253
|
|
93
|
-
##
|
254
|
+
## 0.5.0 2018-05-03
|
94
255
|
|
95
|
-
* `constructor_type` was removed, use `transform_types` and `transform_keys` as a replacement (see below)
|
96
|
-
* Default types are evaluated _only_ on missing values. Again, use `tranform_types` as a work around for `nil`s
|
97
|
-
* Values are now stored within a single instance variable names `@attributes`, this sped up struct creation and improved support for reserved attribute names such as `hash`, they don't get a getter but still can be read via `#[]`
|
98
|
-
* Ruby 2.3 is a minimal supported version
|
99
256
|
|
100
|
-
|
257
|
+
### Added
|
101
258
|
|
102
|
-
|
259
|
+
- `Dry::Struct.transform_types` accepts a block which is yielded on every type to add. Since types are `dry-types`' objects that come with a robust DSL it's rather simple to restore the behavior of `constructor_type`. See https://github.com/dry-rb/dry-struct/pull/64 for details (flash-gordon)
|
103
260
|
|
104
261
|
Example: evaluate defaults on `nil` values
|
105
262
|
|
@@ -110,18 +267,15 @@
|
|
110
267
|
end
|
111
268
|
end
|
112
269
|
```
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
* `Dry.Struct` builds a struct by a hash of attribute names and types (citizen428)
|
270
|
+
- `Data::Struct.transform_keys` accepts a block/proc that transforms keys of input hashes. The most obvious usage is simbolization but arbitrary transformations are allowed (flash-gordon)
|
271
|
+
- `Dry.Struct` builds a struct by a hash of attribute names and types (citizen428)
|
117
272
|
|
118
273
|
```ruby
|
119
274
|
User = Dry::Struct(name: 'strict.string') do
|
120
275
|
attribute :email, 'strict.string'
|
121
276
|
end
|
122
277
|
```
|
123
|
-
|
124
|
-
* Support for `Struct.meta`, note that `.meta` returns a _new class_ (flash-gordon)
|
278
|
+
- Support for `Struct.meta`, note that `.meta` returns a _new class_ (flash-gordon)
|
125
279
|
|
126
280
|
```ruby
|
127
281
|
class User < Dry::Struct
|
@@ -132,8 +286,7 @@
|
|
132
286
|
|
133
287
|
User.new(name: 'Jade').class == UserWithMeta.new(name: 'Jade').class # => false
|
134
288
|
```
|
135
|
-
|
136
|
-
* `Struct.attribute` yields a block with definition for nested structs. It defines a nested constant for the new struct and supports arrays (AMHOL + flash-gordon)
|
289
|
+
- `Struct.attribute` yields a block with definition for nested structs. It defines a nested constant for the new struct and supports arrays (AMHOL + flash-gordon)
|
137
290
|
|
138
291
|
```ruby
|
139
292
|
class User < Dry::Struct
|
@@ -151,92 +304,103 @@
|
|
151
304
|
# ^This automatically defines User::Address and User::Account
|
152
305
|
```
|
153
306
|
|
154
|
-
|
307
|
+
### Fixed
|
308
|
+
|
309
|
+
- Adding a new attribute invalidates `attribute_names` (flash-gordon)
|
310
|
+
- 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)
|
155
311
|
|
156
|
-
* Adding a new attribute invalidates `attribute_names` (flash-gordon)
|
157
|
-
* 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)
|
158
312
|
|
159
313
|
[Compare v0.4.0...v0.5.0](https://github.com/dry-rb/dry-struct/compare/v0.4.0...v0.5.0)
|
160
314
|
|
161
|
-
|
315
|
+
## 0.4.0 2017-11-04
|
316
|
+
|
162
317
|
|
163
|
-
|
318
|
+
### Fixed
|
164
319
|
|
165
|
-
|
166
|
-
* `Struct#new` uses raw attributes instead of method calls, this makes the behavior consistent with the change above (flash-gordon)
|
167
|
-
* `constructor_type` now actively rejects `:weak` and `:symbolized` values (GustavoCaso)
|
320
|
+
- `Struct#new` doesn't call `.to_hash` recursively (flash-gordon)
|
168
321
|
|
169
|
-
|
322
|
+
### Changed
|
170
323
|
|
171
|
-
|
324
|
+
- Attribute readers don't override existing instance methods (solnic)
|
325
|
+
- `Struct#new` uses raw attributes instead of method calls, this makes the behavior consistent with the change above (flash-gordon)
|
326
|
+
- `constructor_type` now actively rejects `:weak` and `:symbolized` values (GustavoCaso)
|
172
327
|
|
173
328
|
[Compare v0.3.1...v0.4.0](https://github.com/dry-rb/dry-struct/compare/v0.3.1...v0.4.0)
|
174
329
|
|
175
|
-
|
330
|
+
## 0.3.1 2017-06-30
|
176
331
|
|
177
|
-
## Added
|
178
332
|
|
179
|
-
|
180
|
-
|
181
|
-
|
333
|
+
### Added
|
334
|
+
|
335
|
+
- `Struct.constructor` that makes dry-struct more aligned with dry-types; now you can have a struct with a custom constructor that will be called _before_ calling the `new` method (v-kolesnikov)
|
336
|
+
- `Struct.attribute?` and `Struct.attribute_names` for introspecting struct attributes (flash-gordon)
|
337
|
+
- `Struct#__new__` is a safe-to-use-in-gems alias for `Struct#new` (flash-gordon)
|
338
|
+
|
182
339
|
|
183
340
|
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-struct/compare/v0.3.0...v0.3.1)
|
184
341
|
|
185
|
-
|
342
|
+
## 0.3.0 2017-05-05
|
343
|
+
|
186
344
|
|
187
|
-
|
345
|
+
### Added
|
188
346
|
|
189
|
-
|
347
|
+
- `Dry::Struct#new` method to return new instance with applied changeset (Kukunin)
|
190
348
|
|
191
|
-
|
349
|
+
### Fixed
|
192
350
|
|
193
|
-
|
194
|
-
|
351
|
+
- `.[]` and `.call` does not coerce subclass to superclass anymore (Kukunin)
|
352
|
+
- Raise ArgumentError when attribute type is a string and no value provided is for `new` (GustavoCaso)
|
195
353
|
|
196
|
-
|
354
|
+
### Changed
|
197
355
|
|
198
|
-
|
356
|
+
- `.new` without arguments doesn't use nil as an input for non-default types anymore (flash-gordon)
|
199
357
|
|
200
358
|
[Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-struct/compare/v0.2.1...v0.3.0)
|
201
359
|
|
202
|
-
|
360
|
+
## 0.2.1 2017-02-27
|
203
361
|
|
204
|
-
## Fixed
|
205
362
|
|
206
|
-
|
363
|
+
### Fixed
|
364
|
+
|
365
|
+
- Fixed `Dry::Struct::Value` which appeared to be broken in the last release (flash-gordon)
|
366
|
+
|
207
367
|
|
208
368
|
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-struct/compare/v0.2.0...v0.2.1)
|
209
369
|
|
210
|
-
|
370
|
+
## 0.2.0 2016-02-26
|
371
|
+
|
211
372
|
|
212
|
-
|
373
|
+
### Changed
|
213
374
|
|
214
|
-
|
375
|
+
- Struct attributes can be overridden in a subclass (flash-gordon)
|
215
376
|
|
216
377
|
[Compare v0.1.1...v0.2.0](https://github.com/dry-rb/dry-struct/compare/v0.1.1...v0.2.0)
|
217
378
|
|
218
|
-
|
379
|
+
## 0.1.1 2016-11-13
|
219
380
|
|
220
|
-
## Fixed
|
221
381
|
|
222
|
-
|
382
|
+
### Fixed
|
383
|
+
|
384
|
+
- Make `Dry::Struct` act as a constrained type. This fixes the behavior of sum types containing structs (flash-gordon)
|
385
|
+
|
223
386
|
|
224
387
|
[Compare v0.1.0...v0.1.1](https://github.com/dry-rb/dry-struct/compare/v0.1.0...v0.1.1)
|
225
388
|
|
226
|
-
|
389
|
+
## 0.1.0 2016-09-21
|
390
|
+
|
227
391
|
|
228
|
-
|
392
|
+
### Added
|
229
393
|
|
230
|
-
|
394
|
+
- `:strict_with_defaults` constructor type (backus)
|
231
395
|
|
232
|
-
|
396
|
+
### Changed
|
233
397
|
|
234
|
-
|
235
|
-
|
236
|
-
|
398
|
+
- [BREAKING] `:strict` was renamed to `:permissive` as it ignores missing keys (backus)
|
399
|
+
- [BREAKING] `:strict` now raises on unexpected keys (backus)
|
400
|
+
- 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)
|
237
401
|
|
238
402
|
[Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-struct/compare/v0.0.1...v0.1.0)
|
239
403
|
|
240
|
-
|
404
|
+
## 0.0.1 2016-07-17
|
241
405
|
|
242
406
|
Initial release of code imported from dry-types
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2015-2022 dry-rb team
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,25 +1,30 @@
|
|
1
|
+
<!--- this file is synced from dry-rb/template-gem project -->
|
1
2
|
[gem]: https://rubygems.org/gems/dry-struct
|
2
|
-
[
|
3
|
-
[
|
4
|
-
[inchpages]: http://inch-ci.org/github/dry-rb/dry-struct
|
3
|
+
[actions]: https://github.com/dry-rb/dry-struct/actions
|
4
|
+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-struct
|
5
5
|
[chat]: https://dry-rb.zulipchat.com
|
6
|
+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-struct
|
6
7
|
|
7
8
|
# dry-struct [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
|
8
9
|
|
9
10
|
[![Gem Version](https://badge.fury.io/rb/dry-struct.svg)][gem]
|
10
|
-
[![
|
11
|
-
[![
|
12
|
-
[![
|
13
|
-
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-struct.svg?branch=
|
11
|
+
[![CI Status](https://github.com/dry-rb/dry-struct/workflows/ci/badge.svg)][actions]
|
12
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/961f5c776f1d49218b2cede3745e059c)][codacy]
|
13
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/961f5c776f1d49218b2cede3745e059c)][codacy]
|
14
|
+
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-struct.svg?branch=main)][inchpages]
|
15
|
+
|
16
|
+
## Links
|
14
17
|
|
15
|
-
|
18
|
+
* [User documentation](https://dry-rb.org/gems/dry-struct)
|
19
|
+
* [API documentation](http://rubydoc.info/gems/dry-struct)
|
16
20
|
|
17
|
-
##
|
21
|
+
## Supported Ruby versions
|
18
22
|
|
19
|
-
|
23
|
+
This library officially supports the following Ruby versions:
|
20
24
|
|
21
|
-
|
25
|
+
* MRI `>= 2.7.0`
|
26
|
+
* jruby `>= 9.3` (postponed until 2.7 is supported)
|
22
27
|
|
23
|
-
##
|
28
|
+
## License
|
24
29
|
|
25
|
-
|
30
|
+
See `LICENSE` file.
|
data/dry-struct.gemspec
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# this file is synced from dry-rb/template-gem project
|
4
|
+
|
5
|
+
lib = File.expand_path("lib", __dir__)
|
2
6
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
7
|
+
require "dry/struct/version"
|
4
8
|
|
5
9
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
10
|
+
spec.name = "dry-struct"
|
11
|
+
spec.authors = ["Piotr Solnica"]
|
12
|
+
spec.email = ["piotr.solnica@gmail.com"]
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.version = Dry::Struct::VERSION.dup
|
11
15
|
|
12
|
-
spec.summary =
|
16
|
+
spec.summary = "Typed structs and value objects"
|
13
17
|
spec.description = spec.summary
|
14
|
-
spec.homepage =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
spec.
|
29
|
-
spec.
|
30
|
-
spec.
|
31
|
-
|
32
|
-
|
33
|
-
spec.
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
|
37
|
-
spec.add_development_dependency 'bundler'
|
38
|
-
spec.add_development_dependency 'rake', '~> 11.0'
|
39
|
-
spec.add_development_dependency 'rspec', '~> 3.3'
|
40
|
-
spec.add_development_dependency 'yard', '~> 0.9.5'
|
18
|
+
spec.homepage = "https://dry-rb.org/gems/dry-struct"
|
19
|
+
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-struct.gemspec", "lib/**/*"]
|
20
|
+
spec.bindir = "bin"
|
21
|
+
spec.executables = []
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-struct/blob/main/CHANGELOG.md"
|
26
|
+
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-struct"
|
27
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-struct/issues"
|
28
|
+
|
29
|
+
spec.required_ruby_version = ">= 2.7.0"
|
30
|
+
|
31
|
+
# to update dependencies edit project.yml
|
32
|
+
spec.add_runtime_dependency "dry-core", "~> 1.0", "< 2"
|
33
|
+
spec.add_runtime_dependency "dry-types", ">= 1.7", "< 2"
|
34
|
+
spec.add_runtime_dependency "ice_nine", "~> 0.11"
|
35
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler"
|
38
|
+
spec.add_development_dependency "rake"
|
39
|
+
spec.add_development_dependency "rspec"
|
40
|
+
spec.add_development_dependency "yard"
|
41
41
|
end
|