dry-types 0.13.4 → 0.14.0

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: cbf4d67993d24ac6ee54193a12a7ad872078216a115ca170368899d6ce8ec5ea
4
- data.tar.gz: a0fcfa2eb7abb090b0c182e596e2b2b3c5cdcb28b0065fe23a91a7b7daa0af01
3
+ metadata.gz: 108086e1690cb76a8333da83b42c1f2a4b46f9abbb08b2bd878463dfa87fd524
4
+ data.tar.gz: ae1430a7067084dcb2945d230ed527677db095ca93bd58df965d2cb3d3069734
5
5
  SHA512:
6
- metadata.gz: 7baab2ddb3433498905dc143d299ed4af015d416744a14cb7ebc69d3102d0c6b7c58a1c66859d817003b6c49660cee8fd73d3448e1669cedd87666df3927ce48
7
- data.tar.gz: 628520f10cfd2d3bfe64313d4528197e542087c8218967fd05c29cd360b0e04a913394711b892dcdd374f544ee01bc5d581c3b707dab4d4d82d67f4010ba8e8e
6
+ metadata.gz: 4627bd45f3992571ba33cc506a0cfc5904e5763e06c0bc2a92dc757e775bb46f3ece7162b7269af4acca97758f61229f5376afce5692a34ceda78bc73cd0bc07
7
+ data.tar.gz: 99fffa1826139214ae7b1abcc6f2a33d6c1280e8cffa528f7dbf33251434d0b0104eef5fb9047c0fedf02aa5bd428df142d0a05457c32c2a530fb0088947ea56
@@ -1,28 +1,29 @@
1
1
  language: ruby
2
- dist: trusty
3
- sudo: required
4
2
  cache: bundler
3
+ sudo: false
5
4
  bundler_args: --without benchmarks tools
5
+ before_script:
6
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
7
+ - chmod +x ./cc-test-reporter
8
+ - ./cc-test-reporter before-build
9
+ after_script:
10
+ - "[ -d coverage ] && ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
6
11
  script:
7
12
  - bundle exec rake
8
- before_install:
9
- - gem update --system
10
- after_success:
11
- - '[ -d coverage ] && bundle exec codeclimate-test-reporter'
12
13
  rvm:
13
- - 2.3.6
14
- - 2.4.3
15
- - 2.5.0
16
- - jruby-9.1.15.0
14
+ - 2.6.0
15
+ - 2.5.3
16
+ - 2.4.5
17
+ - 2.3.8
18
+ - jruby-9.2.5.0
17
19
  env:
18
20
  global:
19
21
  - COVERAGE=true
20
- - JRUBY_OPTS='--dev -J-Xmx1024M'
21
22
  notifications:
22
23
  email: false
23
24
  webhooks:
24
25
  urls:
25
26
  - https://webhooks.gitter.im/e/19098b4253a72c9796db
26
- on_success: change # options: [always|never|change] default: always
27
- on_failure: always # options: [always|never|change] default: always
28
- on_start: false # default: false
27
+ on_success: change # options: [always|never|change] default: always
28
+ on_failure: always # options: [always|never|change] default: always
29
+ on_start: false # default: false
@@ -1,14 +1,27 @@
1
+ # 0.14.0
2
+
3
+ ## Changed
4
+
5
+ - [BREAKING] Support for Ruby 2.2 was dropped. It reached EOL on March 31, 2018.
6
+ - `dry-logic` was updated to `~> 0.5` (solnic)
7
+
8
+ ## Fixed
9
+
10
+ - `valid?` works correctly with constructors now (cgeorgii)
11
+
12
+ [Compare v0.13.4...v0.14.0](https://github.com/dry-rb/dry-types/compare/v0.13.4...v0.14.0)
13
+
1
14
  # v0.13.4 2018-12-21
2
15
 
3
16
  ## Fixed
4
17
 
5
- * Fixed warnings about keyword arguments from Ruby 2.6. See https://bugs.ruby-lang.org/issues/14183 for all the details (flash-gordon)
18
+ - Fixed warnings about keyword arguments from Ruby 2.6. See https://bugs.ruby-lang.org/issues/14183 for all the details (flash-gordon)
6
19
 
7
20
  # v0.13.3 2018-11-25
8
21
 
9
22
  ## Fixed
10
23
 
11
- * `Dry::Types::Hash#try` returns `Failure` instead of throwing an exception on missing keys (GustavoCaso)
24
+ - `Dry::Types::Hash#try` returns `Failure` instead of throwing an exception on missing keys (GustavoCaso)
12
25
 
13
26
  [Compare v0.13.2...v0.13.3](https://github.com/dry-rb/dry-types/compare/v0.13.2...v0.13.3)
14
27
 
@@ -16,8 +29,8 @@
16
29
 
17
30
  ## Fixed
18
31
 
19
- * `Defaults#valid?` now works fine when passing `Dry::Core::Constans::Undefined` as value (GustavoCaso)
20
- * `valid?` for constructor types wrapping `Sum`s (GustavoCaso)
32
+ - `Defaults#valid?` now works fine when passing `Dry::Core::Constans::Undefined` as value (GustavoCaso)
33
+ - `valid?` for constructor types wrapping `Sum`s (GustavoCaso)
21
34
 
22
35
  [Compare v0.13.1...v0.13.2](https://github.com/dry-rb/dry-types/compare/v0.13.1...v0.13.2)
23
36
 
@@ -25,12 +38,12 @@
25
38
 
26
39
  ## Fixed
27
40
 
28
- * Defaults now works fine with meta (GustavoCaso)
29
- * Defaults are now re-decorated properly (flash-gordon)
41
+ - Defaults now works fine with meta (GustavoCaso)
42
+ - Defaults are now re-decorated properly (flash-gordon)
30
43
 
31
44
  ## Added
32
45
 
33
- * `params.int` was added to make the upgrade process in dry-validation smoother (available after you `require 'dry/types/compat/int'`) (flash-gordon)
46
+ - `params.int` was added to make the upgrade process in dry-validation smoother (available after you `require 'dry/types/compat/int'`) (flash-gordon)
34
47
 
35
48
  [Compare v0.13.0...v0.13.1](https://github.com/dry-rb/dry-types/compare/v0.13.0...v0.13.1)
36
49
 
@@ -38,32 +51,31 @@
38
51
 
39
52
  ## Changed
40
53
 
41
- * [BREAKING] Renamed `Types::Form` to `Types::Params`. You can opt-in the former name with `require 'dry/types/compat/form_types'`. It will be dropped in the next release (ndrluis)
42
- * [BREAKING] The `Int` types was renamed to `Integer`, this was the only type named differently from the standard Ruby classes so it has been made consistent. The former name is available with `require 'dry/types/compat/int'` (GustavoCaso + flash-gordon)
43
- * [BREAKING] Default types are not evaluated on `nil`. Default values are evaluated _only_ if no value were given.
54
+ - [BREAKING] Renamed `Types::Form` to `Types::Params`. You can opt-in the former name with `require 'dry/types/compat/form_types'`. It will be dropped in the next release (ndrluis)
55
+ - [BREAKING] The `Int` types was renamed to `Integer`, this was the only type named differently from the standard Ruby classes so it has been made consistent. The former name is available with `require 'dry/types/compat/int'` (GustavoCaso + flash-gordon)
56
+ - [BREAKING] Default types are not evaluated on `nil`. Default values are evaluated _only_ if no value were given.
44
57
  ```ruby
45
58
  type = Types::Strict::String.default("hello")
46
59
  type[nil] # => constraint error
47
60
  type[] # => "hello"
48
61
  ```
49
62
  This change allowed to greatly simplify hash schemas, make them a lot more flexible yet predictable (see below).
50
- * [BREAKING] `Dry::Types.register_class` was removed, `Dry::Types.register` was made private API, do not register your types in the global `dry-types` container, use a module instead, e.g. `Types` (flash-gordon)
51
- * [BREAKING] Enum types don't accept value index anymore. Instead, explicit mapping is supported, see below (flash-gordon)
52
-
63
+ - [BREAKING] `Dry::Types.register_class` was removed, `Dry::Types.register` was made private API, do not register your types in the global `dry-types` container, use a module instead, e.g. `Types` (flash-gordon)
64
+ - [BREAKING] Enum types don't accept value index anymore. Instead, explicit mapping is supported, see below (flash-gordon)
53
65
 
54
66
  ## Added
55
67
 
56
- * Hash schemas were rewritten. The old API is still around but is going to be deprecated and removed before 1.0. The new API is simpler and more flexible. Instead of having a bunch of predefined schemas you can build your own by combining the following methods:
68
+ - Hash schemas were rewritten. The old API is still around but is going to be deprecated and removed before 1.0. The new API is simpler and more flexible. Instead of having a bunch of predefined schemas you can build your own by combining the following methods:
57
69
 
58
70
  1. `Schema#with_key_transform`—transforms keys of input hashes, for things like symbolizing etc.
59
71
  2. `Schema#strict`—makes a schema intolerant to unknown keys.
60
72
  3. `Hash#with_type_transform`—transforms member types with an arbitrary block. For instance,
61
73
 
62
- ```ruby
63
- optional_keys = Types::Hash.with_type_transform { |t, _key| t.optional }
64
- schema = optional_keys.schema(name: 'strict.string', age: 'strict.int')
65
- schema.(name: "Jane", age: nil) # => {name: "Jane", age: nil}
66
- ```
74
+ ```ruby
75
+ optional_keys = Types::Hash.with_type_transform { |t, _key| t.optional }
76
+ schema = optional_keys.schema(name: 'strict.string', age: 'strict.int')
77
+ schema.(name: "Jane", age: nil) # => {name: "Jane", age: nil}
78
+ ```
67
79
 
68
80
  Note that by default all keys are required, if a key is expected to be absent, add to the corresponding type's meta `omittable: true`:
69
81
 
@@ -90,14 +102,14 @@
90
102
 
91
103
  (flash-gordon)
92
104
 
93
- * `Types.Strict` is an alias for `Types.Instance` (flash-gordon)
105
+ - `Types.Strict` is an alias for `Types.Instance` (flash-gordon)
94
106
  ```ruby
95
107
  strict_range = Types.Strict(Range)
96
108
  strict_range == Types.Instance(Range) # => true
97
109
  ```
98
- * `Enum#include?` is an alias to `Enum#valid?` (d-Pixie + flash-gordon)
99
- * `Range` was added (GustavoCaso)
100
- * `Array` types filter out `Undefined` values, if you have an array type with a constructor type as its member, the constructor now can return `Dry::Types::Undefined` to indicate empty value:
110
+ - `Enum#include?` is an alias to `Enum#valid?` (d-Pixie + flash-gordon)
111
+ - `Range` was added (GustavoCaso)
112
+ - `Array` types filter out `Undefined` values, if you have an array type with a constructor type as its member, the constructor now can return `Dry::Types::Undefined` to indicate empty value:
101
113
  ```ruby
102
114
  filter_empty_strings = Types::Strict::Array.of(
103
115
  Types::Strict::String.constructor { |input|
@@ -106,13 +118,13 @@
106
118
  )
107
119
  filter_empty_strings.(["John", nil, "", "Jane"]) # => ["John", "Jane"]
108
120
  ```
109
- * `Types::Map` was added for homogeneous hashes, when only types of keys and values are known in advance, not specific key names (fledman + flash-gordon)
121
+ - `Types::Map` was added for homogeneous hashes, when only types of keys and values are known in advance, not specific key names (fledman + flash-gordon)
110
122
  ```ruby
111
123
  int_to_string = Types::Hash.map('strict.integer', 'strict.string')
112
124
  int_to_string[0 => 'foo'] # => { 0 => "foo" }
113
125
  int_to_string[0 => 1] # Dry::Types::MapError: input value 1 for key 0 is invalid: type?(String, 1)
114
126
  ```
115
- * Enum supports mappings (bolshakov + flash-gordon)
127
+ - Enum supports mappings (bolshakov + flash-gordon)
116
128
  ```ruby
117
129
  dict = Types::Strict::String.enum('draft' => 0, 'published' => 10, 'archived' => 20)
118
130
  dict['published'] # => 'published'
@@ -121,13 +133,13 @@
121
133
 
122
134
  ## Fixed
123
135
 
124
- * Fixed applying constraints to optional type, i.e. `.optional.constrained` works correctly (flash-gordon)
125
- * Fixed enum working with optionals (flash-gordon)
136
+ - Fixed applying constraints to optional type, i.e. `.optional.constrained` works correctly (flash-gordon)
137
+ - Fixed enum working with optionals (flash-gordon)
126
138
 
127
139
  ## Internal
128
140
 
129
- * Dropped the `dry-configurable` dependency (GustavoCaso)
130
- * The gem now uses `dry-inflector` for inflections instead of `inflecto` (GustavoCaso)
141
+ - Dropped the `dry-configurable` dependency (GustavoCaso)
142
+ - The gem now uses `dry-inflector` for inflections instead of `inflecto` (GustavoCaso)
131
143
 
132
144
  [Compare v0.12.2...v0.13.0](https://github.com/dry-rb/dry-types/compare/v0.12.2...v0.13.0)
133
145
 
@@ -135,10 +147,10 @@
135
147
 
136
148
  ## Fixed
137
149
 
138
- * The type compiler was fixed for simple rules such as used for strict type checks (flash-gordon)
139
- * Fixed an error on `Dry::Types['json.decimal'].try(nil)` (nesaulov)
140
- * Fixed an error on calling `try` on an array type built of constrained types (flash-gordon)
141
- * Implemented `===` for enum types (GustavoCaso)
150
+ - The type compiler was fixed for simple rules such as used for strict type checks (flash-gordon)
151
+ - Fixed an error on `Dry::Types['json.decimal'].try(nil)` (nesaulov)
152
+ - Fixed an error on calling `try` on an array type built of constrained types (flash-gordon)
153
+ - Implemented `===` for enum types (GustavoCaso)
142
154
 
143
155
  [Compare v0.12.1...v0.12.2](https://github.com/dry-rb/dry-types/compare/v0.12.1...v0.12.2)
144
156
 
@@ -146,10 +158,10 @@
146
158
 
147
159
  ## Fixed
148
160
 
149
- * `Constructor#try` rescues `ArgumentError` (raised in cases like `Integer('foo')`) (flash-gordon)
150
- * `#constructor` works correctly for default and enum types (solnic)
151
- * Optional sum types work correctly in `safe` mode (GustavoCaso)
152
- * The equalizer of constrained types respects meta (flash-gordon)
161
+ - `Constructor#try` rescues `ArgumentError` (raised in cases like `Integer('foo')`) (flash-gordon)
162
+ - `#constructor` works correctly for default and enum types (solnic)
163
+ - Optional sum types work correctly in `safe` mode (GustavoCaso)
164
+ - The equalizer of constrained types respects meta (flash-gordon)
153
165
 
154
166
  [Compare v0.12.0...v0.12.1](https://github.com/dry-rb/dry-types/compare/v0.12.0...v0.12.1)
155
167
 
@@ -157,11 +169,11 @@
157
169
 
158
170
  ## Added
159
171
 
160
- * A bunch of shortcut methods for constructing types to the autogenerated module, e.g. `Types.Constructor(String, &:to_s)` (flash-gordon)
172
+ - A bunch of shortcut methods for constructing types to the autogenerated module, e.g. `Types.Constructor(String, &:to_s)` (flash-gordon)
161
173
 
162
174
  ## Deprecated
163
175
 
164
- * `Types::Array#member` was deprecated in favor of `Types::Array#of` (flash-gordon)
176
+ - `Types::Array#member` was deprecated in favor of `Types::Array#of` (flash-gordon)
165
177
 
166
178
  [Compare v0.11.1...v0.12.0](https://github.com/dry-rb/dry-types/compare/v0.11.1...v0.12.0)
167
179
 
@@ -169,11 +181,11 @@
169
181
 
170
182
  ## Changed
171
183
 
172
- * Constructors are now equalized using `fn` and `meta` too (flash-gordon)
184
+ - Constructors are now equalized using `fn` and `meta` too (flash-gordon)
173
185
 
174
186
  ## Fixed
175
187
 
176
- * Fixed `Constructor#name` with `Sum`-types (flash-gordon)
188
+ - Fixed `Constructor#name` with `Sum`-types (flash-gordon)
177
189
 
178
190
  [Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-types/compare/v0.11.0...v0.11.1)
179
191
 
@@ -181,9 +193,9 @@
181
193
 
182
194
  ## Added
183
195
 
184
- * `#to_ast` available for all type objects (GustavoCaso)
185
- * `Types::Array#of` as an alias for `#member` (maliqq)
186
- * Detailed failure objects are passed to results which improves constraint violation messages (GustavoCaso)
196
+ - `#to_ast` available for all type objects (GustavoCaso)
197
+ - `Types::Array#of` as an alias for `#member` (maliqq)
198
+ - Detailed failure objects are passed to results which improves constraint violation messages (GustavoCaso)
187
199
 
188
200
  [Compare v0.10.3...v0.11.0](https://github.com/dry-rb/dry-types/compare/v0.10.3...v0.11.0)
189
201
 
@@ -191,7 +203,7 @@
191
203
 
192
204
  ## Added
193
205
 
194
- * Callable defaults accept the underlying type (v-kolesnikov)
206
+ - Callable defaults accept the underlying type (v-kolesnikov)
195
207
 
196
208
  [Compare v0.10.2...v0.10.3](https://github.com/dry-rb/dry-types/compare/v0.10.2...v0.10.3)
197
209
 
@@ -199,7 +211,7 @@
199
211
 
200
212
  ## Fixed
201
213
 
202
- * Fixed `Type#optional?` for sum types (flash-gordon)
214
+ - Fixed `Type#optional?` for sum types (flash-gordon)
203
215
 
204
216
  [Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-types/compare/v0.10.1...v0.10.2)
205
217
 
@@ -207,13 +219,13 @@
207
219
 
208
220
  ## Added
209
221
 
210
- * `Type#optional?` returns true if type is Sum and left is nil (GustavoCaso)
211
- * `Type#pristine` returns a type without `meta` (flash-gordon)
222
+ - `Type#optional?` returns true if type is Sum and left is nil (GustavoCaso)
223
+ - `Type#pristine` returns a type without `meta` (flash-gordon)
212
224
 
213
225
  ## Fixed
214
226
 
215
- * `meta` is used in type equality again (solnic)
216
- * `Any` works correctly with meta again (flash-gordon)
227
+ - `meta` is used in type equality again (solnic)
228
+ - `Any` works correctly with meta again (flash-gordon)
217
229
 
218
230
  [Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-types/compare/v0.10.0...v0.10.1)
219
231
 
@@ -221,16 +233,16 @@
221
233
 
222
234
  ## Added
223
235
 
224
- * Types can be used in `case` statements now (GustavoCaso)
236
+ - Types can be used in `case` statements now (GustavoCaso)
225
237
 
226
238
  ## Fixed
227
239
 
228
- * Return original value when Date.parse raises a RangeError (jviney)
240
+ - Return original value when Date.parse raises a RangeError (jviney)
229
241
 
230
242
  ## Changed
231
243
 
232
- * Meta data are now stored separately from options (flash-gordon)
233
- * `Types::Object` was renamed to `Types::Any` (flash-gordon)
244
+ - Meta data are now stored separately from options (flash-gordon)
245
+ - `Types::Object` was renamed to `Types::Any` (flash-gordon)
234
246
 
235
247
  [Compare v0.9.4...v0.10.0](https://github.com/dry-rb/dry-types/compare/v0.9.4...v0.10.0)
236
248
 
@@ -238,7 +250,7 @@
238
250
 
239
251
  ## Added
240
252
 
241
- * Added `Types::Object` which passes an object of any type (flash-gordon)
253
+ - Added `Types::Object` which passes an object of any type (flash-gordon)
242
254
 
243
255
  [Compare v0.9.3...v0.9.4](https://github.com/dry-rb/dry-types/compare/v0.9.3...v0.9.4)
244
256
 
@@ -246,7 +258,7 @@
246
258
 
247
259
  ## Fixed
248
260
 
249
- * Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
261
+ - Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
250
262
 
251
263
  [Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-types/compare/v0.9.2...v0.9.3)
252
264
 
@@ -254,11 +266,11 @@
254
266
 
255
267
  ## Added
256
268
 
257
- * Support for `"Y"` and `"N"` as `true` and `false` values, respectively (scare21410)
269
+ - Support for `"Y"` and `"N"` as `true` and `false` values, respectively (scare21410)
258
270
 
259
271
  ## Changed
260
272
 
261
- * Optimized object allocation in hash schemas, resulting in up to 25% speed boost (davydovanton)
273
+ - Optimized object allocation in hash schemas, resulting in up to 25% speed boost (davydovanton)
262
274
 
263
275
  [Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-types/compare/v0.9.1...v0.9.2)
264
276
 
@@ -266,11 +278,11 @@
266
278
 
267
279
  ## Fixed
268
280
 
269
- * `Hash#strict_with_defaults` properly evaluates callable defaults (bolshakov)
281
+ - `Hash#strict_with_defaults` properly evaluates callable defaults (bolshakov)
270
282
 
271
283
  ## Changed
272
284
 
273
- * `Hash#weak` accepts Hash-descendants again (solnic)
285
+ - `Hash#weak` accepts Hash-descendants again (solnic)
274
286
 
275
287
  [Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-types/compare/v0.9.0...v0.9.1)
276
288
 
@@ -278,23 +290,23 @@
278
290
 
279
291
  ## Added
280
292
 
281
- * `Hash#strict_with_defaults` which validates presence of all required keys and respects default types for missing *values* (backus)
282
- * `Type#constrained?` method (flash-gordon)
293
+ - `Hash#strict_with_defaults` which validates presence of all required keys and respects default types for missing _values_ (backus)
294
+ - `Type#constrained?` method (flash-gordon)
283
295
 
284
296
  ## Fixed
285
297
 
286
- * Summing two constrained types works correctly (flash-gordon)
287
- * `Types::Array::Member#valid?` in cases where member type is a constraint (solnic)
288
- * `Hash::Schema#try` handles exceptions properly and returns a failure object (solnic)
298
+ - Summing two constrained types works correctly (flash-gordon)
299
+ - `Types::Array::Member#valid?` in cases where member type is a constraint (solnic)
300
+ - `Hash::Schema#try` handles exceptions properly and returns a failure object (solnic)
289
301
 
290
302
  ## Changed
291
303
 
292
- * [BREAKING] Renamed `Hash##{schema=>permissive}` (backus)
293
- * [BREAKING] `dry-monads` dependency was made optional, Maybe types are available after `Dry::Types.load_extensions(:maybe)` (flash-gordon)
294
- * [BREAKING] `Dry::Types::Struct` and `Dry::Types::Value` have been extracted to [`dry-struct`](https://github.com/dry-rb/dry-struct) (backus)
295
- * `Types::Form::Bool` supports upcased true/false values (kirs)
296
- * `Types::Form::{Date,DateTime,Time}` fail gracefully for invalid input (padde)
297
- * ice_nine dependency has been dropped as it was required by Struct only (flash-gordon)
304
+ - [BREAKING] Renamed `Hash##{schema=>permissive}` (backus)
305
+ - [BREAKING] `dry-monads` dependency was made optional, Maybe types are available after `Dry::Types.load_extensions(:maybe)` (flash-gordon)
306
+ - [BREAKING] `Dry::Types::Struct` and `Dry::Types::Value` have been extracted to [`dry-struct`](https://github.com/dry-rb/dry-struct) (backus)
307
+ - `Types::Form::Bool` supports upcased true/false values (kirs)
308
+ - `Types::Form::{Date,DateTime,Time}` fail gracefully for invalid input (padde)
309
+ - ice_nine dependency has been dropped as it was required by Struct only (flash-gordon)
298
310
 
299
311
  [Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-types/compare/v0.8.1...v0.9.0)
300
312
 
@@ -302,8 +314,8 @@
302
314
 
303
315
  ## Fixed
304
316
 
305
- * Compiler no longer chokes on type nodes without args (solnic)
306
- * Removed `bin/console` from gem package (solnic)
317
+ - Compiler no longer chokes on type nodes without args (solnic)
318
+ - Removed `bin/console` from gem package (solnic)
307
319
 
308
320
  [Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-types/compare/v0.8.0...v0.8.1)
309
321
 
@@ -311,19 +323,19 @@
311
323
 
312
324
  ## Added
313
325
 
314
- * `Struct` now implements `Type` interface so ie `SomeStruct | String` works now (flash-gordon)
315
- * `:weak` Hash constructor which can partially coerce a hash even when it includes invalid values (solnic)
316
- * Types include `Dry::Equalizer` now (flash-gordon)
326
+ - `Struct` now implements `Type` interface so ie `SomeStruct | String` works now (flash-gordon)
327
+ - `:weak` Hash constructor which can partially coerce a hash even when it includes invalid values (solnic)
328
+ - Types include `Dry::Equalizer` now (flash-gordon)
317
329
 
318
330
  ## Fixed
319
331
 
320
- * `Struct#to_hash` descends into arrays too (nepalez)
321
- * `Default#with` works now (flash-gordon)
332
+ - `Struct#to_hash` descends into arrays too (nepalez)
333
+ - `Default#with` works now (flash-gordon)
322
334
 
323
335
  ## Changed
324
336
 
325
- * `:symbolized` hash schema is now based on `:weak` schema (solnic)
326
- * `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
337
+ - `:symbolized` hash schema is now based on `:weak` schema (solnic)
338
+ - `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
327
339
 
328
340
  [Compare v0.7.2...v0.8.0](https://github.com/dry-rb/dry-types/compare/v0.7.2...v0.8.0)
329
341
 
@@ -399,32 +411,32 @@ Renamed from `dry-data` to `dry-types` and:
399
411
 
400
412
  ## Added
401
413
 
402
- * `Dry::Types.module` which returns a namespace for inclusion which has all
414
+ - `Dry::Types.module` which returns a namespace for inclusion which has all
403
415
  built-in types defined as constants (solnic)
404
- * `Hash#schema` supports default values now (solnic)
405
- * `Hash#symbolized` passes through keys that are already symbols (solnic)
406
- * `Struct.new` uses an empty hash by default as input (solnic)
407
- * `Struct.constructor_type` macro can be used to change attributes constructor (solnic)
408
- * `default` accepts a block now for dynamic values (solnic)
409
- * `Types.register_class` accepts a second arg which is the name of the class'
416
+ - `Hash#schema` supports default values now (solnic)
417
+ - `Hash#symbolized` passes through keys that are already symbols (solnic)
418
+ - `Struct.new` uses an empty hash by default as input (solnic)
419
+ - `Struct.constructor_type` macro can be used to change attributes constructor (solnic)
420
+ - `default` accepts a block now for dynamic values (solnic)
421
+ - `Types.register_class` accepts a second arg which is the name of the class'
410
422
  constructor method, defaults to `:new` (solnic)
411
423
 
412
424
  ## Fixed
413
425
 
414
- * `Struct` will simply pass-through the input if it is already a struct (solnic)
415
- * `default` will raise if a value violates constraints (solnic)
416
- * Evaluating a default value tries to use type's constructor which makes it work
426
+ - `Struct` will simply pass-through the input if it is already a struct (solnic)
427
+ - `default` will raise if a value violates constraints (solnic)
428
+ - Evaluating a default value tries to use type's constructor which makes it work
417
429
  with types that may coerce an input into nil (solnic)
418
- * `enum` works just fine with integer-values (solnic)
419
- * `enum` + `default` works just fine (solnic)
420
- * `Optional` no longer responds to `primitive` as it makes no sense since there's
430
+ - `enum` works just fine with integer-values (solnic)
431
+ - `enum` + `default` works just fine (solnic)
432
+ - `Optional` no longer responds to `primitive` as it makes no sense since there's
421
433
  no single primitive for an optional value (solnic)
422
- * `Optional` passes-through a value which is already a maybe (solnic)
434
+ - `Optional` passes-through a value which is already a maybe (solnic)
423
435
 
424
436
  ## Changed
425
437
 
426
- * `Dry::Types::Definition` is now the base type definition object (solnic)
427
- * `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
438
+ - `Dry::Types::Definition` is now the base type definition object (solnic)
439
+ - `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
428
440
 
429
441
  [Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-types/compare/v0.5.1...v0.6.0)
430
442
 
@@ -432,9 +444,9 @@ Renamed from `dry-data` to `dry-types` and:
432
444
 
433
445
  ## Added
434
446
 
435
- * `Dry::Data::Type#safe` for types which can skip constructor when primitive does
447
+ - `Dry::Data::Type#safe` for types which can skip constructor when primitive does
436
448
  not match input's class (solnic)
437
- * `form.array` and `form.hash` safe types (solnic)
449
+ - `form.array` and `form.hash` safe types (solnic)
438
450
 
439
451
  [Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-types/compare/v0.5.0...v0.5.1)
440
452
 
@@ -442,20 +454,20 @@ Renamed from `dry-data` to `dry-types` and:
442
454
 
443
455
  ## Added
444
456
 
445
- * `Type#default` interface for defining a type with a default value (solnic)
457
+ - `Type#default` interface for defining a type with a default value (solnic)
446
458
 
447
459
  ## Changed
448
460
 
449
- * [BREAKING] `Dry::Data::Type.new` accepts constructor and *options* now (solnic)
450
- * Renamed `Dry::Data::Type::{Enum,Constrained}` => `Dry::Data::{Enum,Constrained}` (solnic)
451
- * `dry-logic` is now a dependency for constrained types (solnic)
452
- * Constrained types are now always available (solnic)
453
- * `strict.*` category uses constrained types with `:type?` predicate (solnic)
454
- * `SumType#call` no longer needs to rescue from `TypeError` (solnic)
461
+ - [BREAKING] `Dry::Data::Type.new` accepts constructor and _options_ now (solnic)
462
+ - Renamed `Dry::Data::Type::{Enum,Constrained}` => `Dry::Data::{Enum,Constrained}` (solnic)
463
+ - `dry-logic` is now a dependency for constrained types (solnic)
464
+ - Constrained types are now always available (solnic)
465
+ - `strict.*` category uses constrained types with `:type?` predicate (solnic)
466
+ - `SumType#call` no longer needs to rescue from `TypeError` (solnic)
455
467
 
456
468
  ## Fixed
457
469
 
458
- * `attribute` raises proper error when type definition is missing (solnic)
470
+ - `attribute` raises proper error when type definition is missing (solnic)
459
471
 
460
472
  [Compare v0.4.2...v0.5.0](https://github.com/dry-rb/dry-types/compare/v0.4.2...v0.5.0)
461
473
 
@@ -463,11 +475,11 @@ Renamed from `dry-data` to `dry-types` and:
463
475
 
464
476
  ## Added
465
477
 
466
- * Support for arrays in type compiler (solnic)
478
+ - Support for arrays in type compiler (solnic)
467
479
 
468
480
  ## Changed
469
481
 
470
- * Array member uses type objects now rather than just their constructors (solnic)
482
+ - Array member uses type objects now rather than just their constructors (solnic)
471
483
 
472
484
  [Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-types/compare/v0.4.1...v0.4.2)
473
485
 
@@ -475,12 +487,12 @@ Renamed from `dry-data` to `dry-types` and:
475
487
 
476
488
  ## Added
477
489
 
478
- * Support for sum-types with constraint type (solnic)
479
- * `Dry::Data::Type#optional` for defining optional types (solnic)
490
+ - Support for sum-types with constraint type (solnic)
491
+ - `Dry::Data::Type#optional` for defining optional types (solnic)
480
492
 
481
493
  ## Changed
482
494
 
483
- * `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
495
+ - `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
484
496
 
485
497
  [Compare v0.3.2...v0.4.0](https://github.com/dry-rb/dry-types/compare/v0.3.2...v0.4.0)
486
498
 
@@ -488,11 +500,11 @@ Renamed from `dry-data` to `dry-types` and:
488
500
 
489
501
  ## Added
490
502
 
491
- * `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
503
+ - `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
492
504
 
493
505
  ## Fixed
494
506
 
495
- * Added missing require for `dry-equalizer` (solnic)
507
+ - Added missing require for `dry-equalizer` (solnic)
496
508
 
497
509
  [Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-types/compare/v0.3.1...v0.3.2)
498
510
 
@@ -500,7 +512,7 @@ Renamed from `dry-data` to `dry-types` and:
500
512
 
501
513
  ## Changed
502
514
 
503
- * Removed require of constrained type and make it optional (solnic)
515
+ - Removed require of constrained type and make it optional (solnic)
504
516
 
505
517
  [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-types/compare/v0.3.0...v0.3.1)
506
518
 
@@ -508,11 +520,11 @@ Renamed from `dry-data` to `dry-types` and:
508
520
 
509
521
  ## Added
510
522
 
511
- * `Type#constrained` interface for defining constrained types (solnic)
512
- * `Dry::Data` can be configured with a type namespace (solnic)
513
- * `Dry::Data.finalize` can be used to define types as constants under configured namespace (solnic)
514
- * `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
515
- * New types: `symbol` and `class` along with their `strict` versions (solnic)
523
+ - `Type#constrained` interface for defining constrained types (solnic)
524
+ - `Dry::Data` can be configured with a type namespace (solnic)
525
+ - `Dry::Data.finalize` can be used to define types as constants under configured namespace (solnic)
526
+ - `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
527
+ - New types: `symbol` and `class` along with their `strict` versions (solnic)
516
528
 
517
529
  [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-types/compare/v0.2.1...v0.3.0)
518
530
 
@@ -520,15 +532,15 @@ Renamed from `dry-data` to `dry-types` and:
520
532
 
521
533
  ## Added
522
534
 
523
- * Type compiler supports nested hashes now (solnic)
535
+ - Type compiler supports nested hashes now (solnic)
524
536
 
525
537
  ## Fixed
526
538
 
527
- * `form.bool` sum is using correct right-side `form.false` type (solnic)
539
+ - `form.bool` sum is using correct right-side `form.false` type (solnic)
528
540
 
529
541
  ## Changed
530
542
 
531
- * Improved structure of the ast (solnic)
543
+ - Improved structure of the ast (solnic)
532
544
 
533
545
  [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-types/compare/v0.2.0...v0.2.1)
534
546
 
@@ -536,13 +548,13 @@ Renamed from `dry-data` to `dry-types` and:
536
548
 
537
549
  ## Added
538
550
 
539
- * `form.nil` which coerces empty strings to `nil` (solnic)
540
- * `bool` sum-type (true | false) (solnic)
541
- * Type compiler supports sum-types now (solnic)
551
+ - `form.nil` which coerces empty strings to `nil` (solnic)
552
+ - `bool` sum-type (true | false) (solnic)
553
+ - Type compiler supports sum-types now (solnic)
542
554
 
543
555
  ## Changed
544
556
 
545
- * Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
557
+ - Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
546
558
 
547
559
  [Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-types/compare/v0.1.0...v0.2.0)
548
560
 
@@ -550,12 +562,12 @@ Renamed from `dry-data` to `dry-types` and:
550
562
 
551
563
  ## Added
552
564
 
553
- * `form.*` coercible types (solnic)
554
- * `Type::Hash#strict` for defining hashes with a strict schema (solnic)
555
- * `Type::Hash#symbolized` for defining hashes that will symbolize keys (solnic)
556
- * `Dry::Data.register_class` short-cut interface for registering a class and
565
+ - `form.*` coercible types (solnic)
566
+ - `Type::Hash#strict` for defining hashes with a strict schema (solnic)
567
+ - `Type::Hash#symbolized` for defining hashes that will symbolize keys (solnic)
568
+ - `Dry::Data.register_class` short-cut interface for registering a class and
557
569
  setting its `.new` method as the constructor (solnic)
558
- * `Dry::Data::Compiler` for building a type from a simple ast (solnic)
570
+ - `Dry::Data::Compiler` for building a type from a simple ast (solnic)
559
571
 
560
572
  [Compare v0.0.1...HEAD](https://github.com/dry-rb/dry-types/compare/v0.0.1...HEAD)
561
573
 
data/Gemfile CHANGED
@@ -4,7 +4,6 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  platform :mri do
7
- gem "codeclimate-test-reporter", require: false
8
7
  gem 'simplecov', require: false
9
8
  end
10
9
  end
@@ -17,6 +17,9 @@ Gem::Specification.new do |spec|
17
17
  # delete this section to allow pushing this gem to any host.
18
18
  if spec.respond_to?(:metadata)
19
19
  spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ spec.metadata['changelog_uri'] = "https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md"
21
+ spec.metadata['source_code_uri'] = "https://github.com/dry-rb/dry-types"
22
+ spec.metadata['bug_tracker_uri'] = "https://github.com/dry-rb/dry-types/issues"
20
23
  else
21
24
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
25
  end
@@ -25,14 +28,14 @@ Gem::Specification.new do |spec|
25
28
  spec.bindir = "exe"
26
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
30
  spec.require_paths = ["lib"]
28
- spec.required_ruby_version = ">= 2.2.0"
31
+ spec.required_ruby_version = ">= 2.3.0"
29
32
 
30
33
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
31
34
  spec.add_runtime_dependency 'dry-core', '~> 0.4', '>= 0.4.4'
32
35
  spec.add_runtime_dependency 'dry-inflector', '~> 0.1', '>= 0.1.2'
33
36
  spec.add_runtime_dependency 'dry-container', '~> 0.3'
34
37
  spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
35
- spec.add_runtime_dependency 'dry-logic', '~> 0.4', '>= 0.4.2'
38
+ spec.add_runtime_dependency 'dry-logic', '~> 0.5', '>= 0.5'
36
39
 
37
40
  spec.add_development_dependency "bundler", "~> 1.6"
38
41
  spec.add_development_dependency "rake", "~> 11.0"
@@ -1,4 +1,3 @@
1
- require 'dry/types/decorator'
2
1
  require 'dry/types/fn_container'
3
2
 
4
3
  module Dry
@@ -79,7 +78,11 @@ module Dry
79
78
  # @param [Object] value
80
79
  # @return [Boolean]
81
80
  def valid?(value)
82
- type.valid?(value)
81
+ constructed_value = fn[value]
82
+ rescue NoMethodError, TypeError
83
+ false
84
+ else
85
+ type.valid?(constructed_value)
83
86
  end
84
87
  alias_method :===, :valid?
85
88
 
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Types
3
- VERSION = '0.13.4'.freeze
3
+ VERSION = '0.14.0'.freeze
4
4
  end
5
5
  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.13.4
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-21 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -96,22 +96,22 @@ dependencies:
96
96
  name: dry-logic
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '0.4'
102
99
  - - ">="
103
100
  - !ruby/object:Gem::Version
104
- version: 0.4.2
101
+ version: '0.5'
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '0.5'
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '0.4'
112
109
  - - ">="
113
110
  - !ruby/object:Gem::Version
114
- version: 0.4.2
111
+ version: '0.5'
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '0.5'
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: bundler
117
117
  requirement: !ruby/object:Gem::Requirement
@@ -250,6 +250,9 @@ licenses:
250
250
  - MIT
251
251
  metadata:
252
252
  allowed_push_host: https://rubygems.org
253
+ changelog_uri: https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md
254
+ source_code_uri: https://github.com/dry-rb/dry-types
255
+ bug_tracker_uri: https://github.com/dry-rb/dry-types/issues
253
256
  post_install_message:
254
257
  rdoc_options: []
255
258
  require_paths:
@@ -258,14 +261,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
261
  requirements:
259
262
  - - ">="
260
263
  - !ruby/object:Gem::Version
261
- version: 2.2.0
264
+ version: 2.3.0
262
265
  required_rubygems_version: !ruby/object:Gem::Requirement
263
266
  requirements:
264
267
  - - ">="
265
268
  - !ruby/object:Gem::Version
266
269
  version: '0'
267
270
  requirements: []
268
- rubygems_version: 3.0.0.beta3
271
+ rubygems_version: 3.0.2
269
272
  signing_key:
270
273
  specification_version: 4
271
274
  summary: Type system for Ruby supporting coercions, constraints and complex types