dry-types 1.0.0 → 1.0.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 +18 -1
- data/lib/dry/types/builder_methods.rb +16 -0
- data/lib/dry/types/constructor.rb +1 -1
- data/lib/dry/types/schema.rb +2 -2
- data/lib/dry/types/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bb3d91a31885a317b8fda3eef46f77b283abb3781c84124cc7ca0a5a2c30104
|
4
|
+
data.tar.gz: 88cd356e7878080570e5fa659f1403e01d8bc8a9654b3c5cfaf568c851d8e848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 536386eba753a58a499c473d7f9e54da2bccf8597d80e3e225a036fb37acd886e0e9f75ceff497e81e6cb9a47141c2fdf4753f2bd521bf5a53424f768fc0cf0d
|
7
|
+
data.tar.gz: f74042df53c00159132ff2675206a393ca73a0d48ab84f7e6d58d56a51082e570932591279705ec993056b8e2720fd4572657b7bcb90596a16a7addaa7ac4bcf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# 1.0.1 2019-06-04
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- In the case of failure the constructor block can now pass a different value (flash-gordon)
|
6
|
+
```ruby
|
7
|
+
not_empty_string = Types::String.constructor do |value, &failure|
|
8
|
+
value.strip.empty? ? failure.(nil) : value.strip
|
9
|
+
end
|
10
|
+
not_empty_string.(' ') { |v| v } # => nil
|
11
|
+
not_empty_string.lax.(' ') # => nil
|
12
|
+
not_empty_string.lax.(' foo ') # => "foo"
|
13
|
+
```
|
14
|
+
- `Schema#strict` now accepts an boolean argument. If `fales` is passed this will turn a strict schema into a non-strict one (flash-gordon)
|
15
|
+
|
16
|
+
[Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-types/compare/v1.0.0...v1.0.1)
|
17
|
+
|
1
18
|
# 1.0.0 2019-04-23
|
2
19
|
|
3
20
|
## Changed
|
@@ -30,7 +47,7 @@
|
|
30
47
|
|
31
48
|
## Added
|
32
49
|
|
33
|
-
- API for custom constructor types was enhanced. If you pass your own callable to `.constructor` it can have a block in its signature. If a block is passed, you must call it on
|
50
|
+
- API for custom constructor types was enhanced. If you pass your own callable to `.constructor` it can have a block in its signature. If a block is passed, you must call it on failed coercion, otherwise raise a type coercion error (flash-gordon)
|
34
51
|
Example:
|
35
52
|
```ruby
|
36
53
|
proc do |input, &block|
|
@@ -107,6 +107,22 @@ module Dry
|
|
107
107
|
def Map(key_type, value_type)
|
108
108
|
Types['nominal.hash'].map(key_type, value_type)
|
109
109
|
end
|
110
|
+
|
111
|
+
# # Builds a constrained nominal type accepting any value that
|
112
|
+
# # responds to given methods
|
113
|
+
# #
|
114
|
+
# # @example
|
115
|
+
# # Types::Callable = Types.Contract(:call)
|
116
|
+
# # Types::Contact = Types.Contract(:name, :address)
|
117
|
+
# #
|
118
|
+
# # @param methods [Array<String, Symbol>] Method names
|
119
|
+
# #
|
120
|
+
# # @return [Dry::Types::Contrained]
|
121
|
+
# def Contract(*methods)
|
122
|
+
# methods.reduce(Types['nominal.any']) do |type, method|
|
123
|
+
# type.constrained(respond_to: method)
|
124
|
+
# end
|
125
|
+
# end
|
110
126
|
end
|
111
127
|
end
|
112
128
|
end
|
data/lib/dry/types/schema.rb
CHANGED
data/lib/dry/types/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.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: 2019-04
|
11
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|