dry-types 0.10.0 → 0.10.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/.travis.yml +0 -1
- data/CHANGELOG.md +36 -22
- data/lib/dry/types/any.rb +8 -2
- data/lib/dry/types/definition.rb +6 -1
- data/lib/dry/types/options.rb +6 -0
- data/lib/dry/types/sum.rb +11 -1
- data/lib/dry/types/version.rb +1 -1
- data/lib/spec/dry/types.rb +18 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f7f3d17e795bd1fc9393df39d6388e47f20abd5
|
4
|
+
data.tar.gz: caaa567b13b3806de44c36daa5f30d41579c6405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2161c43f4f094bf12e4d5e2e64cd4d48b5a517ff1a3293a25bfda045bbfbe1fe1d7816d4f736e5273dbb4516947aa5342d854d8bab33c634f4c236ed9203e410
|
7
|
+
data.tar.gz: 806dfa70f3950020943c46ee415710d2dc4e45355d3b087bbb8b2c33e6259bca1745a9400dd2f0c4b6f1df4c2d46427d8c02550540ce14e6aa1b2bc691dbd8fa
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# v0.10.1 2017-04-28
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
* `Type#optional?` returns true if type is Sum and left is nil (GustavoCaso)
|
6
|
+
* `Type#pristine` returns a type without `meta` (flash-gordon)
|
7
|
+
|
8
|
+
## Fixed
|
9
|
+
|
10
|
+
* `meta` is used in type equality again (solnic)
|
11
|
+
* `Any` works correctly with meta again (flash-gordon)
|
12
|
+
|
13
|
+
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-types/compare/v0.10.0...v0.10.1)
|
14
|
+
|
1
15
|
# v0.10.0 2017-04-26
|
2
16
|
|
3
17
|
## Added
|
@@ -13,7 +27,7 @@
|
|
13
27
|
* Meta data are now stored separately from options (flash-gordon)
|
14
28
|
* `Types::Object` was renamed to `Types::Any` (flash-gordon)
|
15
29
|
|
16
|
-
[Compare v0.9.4...v0.10.0](https://github.com/
|
30
|
+
[Compare v0.9.4...v0.10.0](https://github.com/dry-rb/dry-types/compare/v0.9.4...v0.10.0)
|
17
31
|
|
18
32
|
# v0.9.4 2017-01-24
|
19
33
|
|
@@ -21,7 +35,7 @@
|
|
21
35
|
|
22
36
|
* Added `Types::Object` which passes an object of any type (flash-gordon)
|
23
37
|
|
24
|
-
[Compare v0.9.3...v0.9.4](https://github.com/
|
38
|
+
[Compare v0.9.3...v0.9.4](https://github.com/dry-rb/dry-types/compare/v0.9.3...v0.9.4)
|
25
39
|
|
26
40
|
# v0.9.3 2016-12-03
|
27
41
|
|
@@ -29,7 +43,7 @@
|
|
29
43
|
|
30
44
|
* Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
|
31
45
|
|
32
|
-
[Compare v0.9.2...v0.9.3](https://github.com/
|
46
|
+
[Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-types/compare/v0.9.2...v0.9.3)
|
33
47
|
|
34
48
|
# v0.9.2 2016-11-13
|
35
49
|
|
@@ -41,7 +55,7 @@
|
|
41
55
|
|
42
56
|
* Optimized object allocation in hash schemas, resulting in up to 25% speed boost (davydovanton)
|
43
57
|
|
44
|
-
[Compare v0.9.1...v0.9.2](https://github.com/
|
58
|
+
[Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-types/compare/v0.9.1...v0.9.2)
|
45
59
|
|
46
60
|
# v0.9.1 2016-11-04
|
47
61
|
|
@@ -53,7 +67,7 @@
|
|
53
67
|
|
54
68
|
* `Hash#weak` accepts Hash-descendants again (solnic)
|
55
69
|
|
56
|
-
[Compare v0.9.0...v0.9.1](https://github.com/
|
70
|
+
[Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-types/compare/v0.9.0...v0.9.1)
|
57
71
|
|
58
72
|
# v0.9.0 2016-09-21
|
59
73
|
|
@@ -77,7 +91,7 @@
|
|
77
91
|
* `Types::Form::{Date,DateTime,Time}` fail gracefully for invalid input (padde)
|
78
92
|
* ice_nine dependency has been dropped as it was required by Struct only (flash-gordon)
|
79
93
|
|
80
|
-
[Compare v0.8.1...v0.9.0](https://github.com/
|
94
|
+
[Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-types/compare/v0.8.1...v0.9.0)
|
81
95
|
|
82
96
|
# v0.8.1 2016-07-13
|
83
97
|
|
@@ -86,7 +100,7 @@
|
|
86
100
|
* Compiler no longer chokes on type nodes without args (solnic)
|
87
101
|
* Removed `bin/console` from gem package (solnic)
|
88
102
|
|
89
|
-
[Compare v0.8.0...v0.8.1](https://github.com/
|
103
|
+
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-types/compare/v0.8.0...v0.8.1)
|
90
104
|
|
91
105
|
# v0.8.0 2016-07-01
|
92
106
|
|
@@ -106,7 +120,7 @@
|
|
106
120
|
* `:symbolized` hash schema is now based on `:weak` schema (solnic)
|
107
121
|
* `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
|
108
122
|
|
109
|
-
[Compare v0.7.2...v0.8.0](https://github.com/
|
123
|
+
[Compare v0.7.2...v0.8.0](https://github.com/dry-rb/dry-types/compare/v0.7.2...v0.8.0)
|
110
124
|
|
111
125
|
# v0.7.2 2016-05-11
|
112
126
|
|
@@ -125,7 +139,7 @@
|
|
125
139
|
- Coerce empty strings in form posts to blank arrays and hashes (timriley)
|
126
140
|
- update to use dry-logic v0.2.3 (fran-worley)
|
127
141
|
|
128
|
-
[Compare v0.7.1...v0.7.2](https://github.com/
|
142
|
+
[Compare v0.7.1...v0.7.2](https://github.com/dry-rb/dry-types/compare/v0.7.1...v0.7.2)
|
129
143
|
|
130
144
|
# v0.7.1 2016-04-06
|
131
145
|
|
@@ -138,7 +152,7 @@
|
|
138
152
|
- Schema is properly inherited in Struct (backus)
|
139
153
|
- `constructor_type` is properly inherited in Struct (fbernier)
|
140
154
|
|
141
|
-
[Compare v0.7.0...v0.7.1](https://github.com/
|
155
|
+
[Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-types/compare/v0.7.0...v0.7.1)
|
142
156
|
|
143
157
|
# v0.7.0 2016-03-30
|
144
158
|
|
@@ -172,7 +186,7 @@ Major focus of this release is to make complex type composition possible and imp
|
|
172
186
|
- `Type#default` will raise if `nil` was passed for `Maybe` type (solnic)
|
173
187
|
- `Hash` with a schema will set maybe values for missing keys or nils (flash-gordon)
|
174
188
|
|
175
|
-
[Compare v0.6.0...v0.7.0](https://github.com/
|
189
|
+
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-types/compare/v0.6.0...v0.7.0)
|
176
190
|
|
177
191
|
# v0.6.0 2016-03-16
|
178
192
|
|
@@ -207,7 +221,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
207
221
|
* `Dry::Types::Definition` is now the base type definition object (solnic)
|
208
222
|
* `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
|
209
223
|
|
210
|
-
[Compare v0.5.1...v0.6.0](https://github.com/
|
224
|
+
[Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-types/compare/v0.5.1...v0.6.0)
|
211
225
|
|
212
226
|
# v0.5.1 2016-01-11
|
213
227
|
|
@@ -217,7 +231,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
217
231
|
not match input's class (solnic)
|
218
232
|
* `form.array` and `form.hash` safe types (solnic)
|
219
233
|
|
220
|
-
[Compare v0.5.0...v0.5.1](https://github.com/
|
234
|
+
[Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-types/compare/v0.5.0...v0.5.1)
|
221
235
|
|
222
236
|
# v0.5.0 2016-01-11
|
223
237
|
|
@@ -238,7 +252,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
238
252
|
|
239
253
|
* `attribute` raises proper error when type definition is missing (solnic)
|
240
254
|
|
241
|
-
[Compare v0.4.2...v0.5.0](https://github.com/
|
255
|
+
[Compare v0.4.2...v0.5.0](https://github.com/dry-rb/dry-types/compare/v0.4.2...v0.5.0)
|
242
256
|
|
243
257
|
# v0.4.2 2015-12-27
|
244
258
|
|
@@ -250,7 +264,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
250
264
|
|
251
265
|
* Array member uses type objects now rather than just their constructors (solnic)
|
252
266
|
|
253
|
-
[Compare v0.4.1...v0.4.2](https://github.com/
|
267
|
+
[Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-types/compare/v0.4.1...v0.4.2)
|
254
268
|
|
255
269
|
# v0.4.0 2015-12-11
|
256
270
|
|
@@ -263,7 +277,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
263
277
|
|
264
278
|
* `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
|
265
279
|
|
266
|
-
[Compare v0.3.2...v0.4.0](https://github.com/
|
280
|
+
[Compare v0.3.2...v0.4.0](https://github.com/dry-rb/dry-types/compare/v0.3.2...v0.4.0)
|
267
281
|
|
268
282
|
# v0.3.2 2015-12-10
|
269
283
|
|
@@ -275,7 +289,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
275
289
|
|
276
290
|
* Added missing require for `dry-equalizer` (solnic)
|
277
291
|
|
278
|
-
[Compare v0.3.1...v0.3.2](https://github.com/
|
292
|
+
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-types/compare/v0.3.1...v0.3.2)
|
279
293
|
|
280
294
|
# v0.3.1 2015-12-09
|
281
295
|
|
@@ -283,7 +297,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
283
297
|
|
284
298
|
* Removed require of constrained type and make it optional (solnic)
|
285
299
|
|
286
|
-
[Compare v0.3.0...v0.3.1](https://github.com/
|
300
|
+
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-types/compare/v0.3.0...v0.3.1)
|
287
301
|
|
288
302
|
# v0.3.0 2015-12-09
|
289
303
|
|
@@ -295,7 +309,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
295
309
|
* `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
|
296
310
|
* New types: `symbol` and `class` along with their `strict` versions (solnic)
|
297
311
|
|
298
|
-
[Compare v0.2.1...v0.3.0](https://github.com/
|
312
|
+
[Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-types/compare/v0.2.1...v0.3.0)
|
299
313
|
|
300
314
|
# v0.2.1 2015-11-30
|
301
315
|
|
@@ -311,7 +325,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
311
325
|
|
312
326
|
* Improved structure of the ast (solnic)
|
313
327
|
|
314
|
-
[Compare v0.2.0...v0.2.1](https://github.com/
|
328
|
+
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-types/compare/v0.2.0...v0.2.1)
|
315
329
|
|
316
330
|
# v0.2.0 2015-11-29
|
317
331
|
|
@@ -325,7 +339,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
325
339
|
|
326
340
|
* Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
|
327
341
|
|
328
|
-
[Compare v0.1.0...v0.2.0](https://github.com/
|
342
|
+
[Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-types/compare/v0.1.0...v0.2.0)
|
329
343
|
|
330
344
|
# v0.1.0 2015-11-27
|
331
345
|
|
@@ -338,7 +352,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
338
352
|
setting its `.new` method as the constructor (solnic)
|
339
353
|
* `Dry::Data::Compiler` for building a type from a simple ast (solnic)
|
340
354
|
|
341
|
-
[Compare v0.0.1...HEAD](https://github.com/
|
355
|
+
[Compare v0.0.1...HEAD](https://github.com/dry-rb/dry-types/compare/v0.0.1...HEAD)
|
342
356
|
|
343
357
|
# v0.0.1 2015-10-05
|
344
358
|
|
data/lib/dry/types/any.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Dry
|
2
2
|
module Types
|
3
3
|
Any = Class.new(Definition) do
|
4
|
-
def initialize
|
5
|
-
super(::Object)
|
4
|
+
def initialize(**options)
|
5
|
+
super(::Object, options)
|
6
6
|
end
|
7
7
|
|
8
8
|
# @return [String]
|
@@ -15,6 +15,12 @@ module Dry
|
|
15
15
|
def valid?(_)
|
16
16
|
true
|
17
17
|
end
|
18
|
+
|
19
|
+
# @param [Hash] new_options
|
20
|
+
# @return [Type]
|
21
|
+
def with(new_options)
|
22
|
+
self.class.new(**options, meta: @meta, **new_options)
|
23
|
+
end
|
18
24
|
end.new
|
19
25
|
end
|
20
26
|
end
|
data/lib/dry/types/definition.rb
CHANGED
@@ -6,7 +6,7 @@ module Dry
|
|
6
6
|
module Types
|
7
7
|
class Definition
|
8
8
|
include Type
|
9
|
-
include Dry::Equalizer(:primitive, :options)
|
9
|
+
include Dry::Equalizer(:primitive, :options, :meta)
|
10
10
|
include Options
|
11
11
|
include Builder
|
12
12
|
|
@@ -51,6 +51,11 @@ module Dry
|
|
51
51
|
false
|
52
52
|
end
|
53
53
|
|
54
|
+
# @return [false]
|
55
|
+
def optional?
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
54
59
|
# @param [BasicObject] input
|
55
60
|
# @return [BasicObject]
|
56
61
|
def call(input)
|
data/lib/dry/types/options.rb
CHANGED
data/lib/dry/types/sum.rb
CHANGED
@@ -4,7 +4,7 @@ module Dry
|
|
4
4
|
module Types
|
5
5
|
class Sum
|
6
6
|
include Type
|
7
|
-
include Dry::Equalizer(:left, :right, :options)
|
7
|
+
include Dry::Equalizer(:left, :right, :options, :meta)
|
8
8
|
include Builder
|
9
9
|
include Options
|
10
10
|
|
@@ -25,6 +25,11 @@ module Dry
|
|
25
25
|
true
|
26
26
|
end
|
27
27
|
|
28
|
+
# @return [Boolean]
|
29
|
+
def optional?
|
30
|
+
left.primitive == NilClass
|
31
|
+
end
|
32
|
+
|
28
33
|
# @param [Object] input
|
29
34
|
# @return [Object]
|
30
35
|
# @raise [ConstraintError] if given +input+ not passing {#try}
|
@@ -65,6 +70,11 @@ module Dry
|
|
65
70
|
false
|
66
71
|
end
|
67
72
|
|
73
|
+
# @return [Boolean]
|
74
|
+
def optional?
|
75
|
+
left.primitive == NilClass
|
76
|
+
end
|
77
|
+
|
68
78
|
# @param [Object] input
|
69
79
|
# @return [Object]
|
70
80
|
def call(input)
|
data/lib/dry/types/version.rb
CHANGED
data/lib/spec/dry/types.rb
CHANGED
@@ -32,6 +32,12 @@ RSpec.shared_examples_for 'Dry::Types::Definition without primitive' do
|
|
32
32
|
expect(type).to eq(type)
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
describe '#optional?' do
|
37
|
+
it 'returns a boolean value' do
|
38
|
+
expect(type.optional?).to be_boolean
|
39
|
+
end
|
40
|
+
end
|
35
41
|
end
|
36
42
|
|
37
43
|
RSpec.shared_examples_for 'Dry::Types::Definition#meta' do
|
@@ -43,9 +49,18 @@ RSpec.shared_examples_for 'Dry::Types::Definition#meta' do
|
|
43
49
|
expect(with_meta.meta).to eql(foo: :bar, baz: '1')
|
44
50
|
end
|
45
51
|
|
46
|
-
it
|
47
|
-
expect(type
|
48
|
-
|
52
|
+
it 'equalizes on empty meta' do
|
53
|
+
expect(type).to eql(type.meta({}))
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'equalizes on filled meta' do
|
57
|
+
expect(type).to_not eql(type.meta(i_am: 'different'))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#pristine' do
|
62
|
+
it 'erases meta' do
|
63
|
+
expect(type.meta(foo: :bar).pristine).to eql(type)
|
49
64
|
end
|
50
65
|
end
|
51
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|