dry-types 1.3.1 → 1.4.0
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 +13 -1
- data/lib/dry/types/coercions.rb +0 -17
- data/lib/dry/types/coercions/json.rb +17 -0
- data/lib/dry/types/coercions/params.rb +17 -0
- 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: f734c560178356c131ffab93f54a26d5e3cd48c0493c5defba166773fa17d992
|
4
|
+
data.tar.gz: 3920839f32bbe474d2e99776dc631bfa079139b099aeb9cbb3c00c45f0e56cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86397faca01543a8836b9d48f6c5bb70084c51219651f137e308d968de42e1f04cb2a8f3b53e3aa362537a35818a0ba54c3fa731521a87e33e62afc2f5ac94d8
|
7
|
+
data.tar.gz: 8b97e1b888936595ef5808a6d5ad6ef5d9e0cf0f52c44f5802831e8dbd1c6bbba2ef4a60ad896b505ed086869ba8977bc87a8053aff10b582ab16316f5829900
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
## 1.4.0 2020-03-09
|
2
|
+
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
|
6
|
+
- `json.nil` no longer coerces empty strings to `nil`. It was a long-standing
|
7
|
+
bug that for some reason remained unnoticed for years. Technically,
|
8
|
+
this may be a breaking change for JSON schemas described with dry-schema (@flash-gordon)
|
9
|
+
|
10
|
+
|
11
|
+
[Compare v1.3.1...v1.4.0](https://github.com/dry-rb/dry-types/compare/v1.3.1...v1.4.0)
|
12
|
+
|
1
13
|
## 1.3.1 2020-02-17
|
2
14
|
|
3
15
|
|
4
16
|
### Changed
|
5
17
|
|
6
|
-
- Predicate inferrer now returns `hash?` for hash schemas. Note, it doesn't spit more complex
|
18
|
+
- Predicate inferrer now returns `hash?` for hash schemas. Note, it doesn't spit more complex preds because we have different plans for dry-schema (@flash-gordon)
|
7
19
|
|
8
20
|
[Compare v1.3.0...v1.3.1](https://github.com/dry-rb/dry-types/compare/v1.3.0...v1.3.1)
|
9
21
|
|
data/lib/dry/types/coercions.rb
CHANGED
@@ -8,23 +8,6 @@ module Dry
|
|
8
8
|
module Coercions
|
9
9
|
include Dry::Core::Constants
|
10
10
|
|
11
|
-
# @param [String, Object] input
|
12
|
-
#
|
13
|
-
# @return [nil] if the input is an empty string or nil
|
14
|
-
#
|
15
|
-
# @raise CoercionError
|
16
|
-
#
|
17
|
-
# @api public
|
18
|
-
def to_nil(input, &_block)
|
19
|
-
if input.nil? || empty_str?(input)
|
20
|
-
nil
|
21
|
-
elsif block_given?
|
22
|
-
yield
|
23
|
-
else
|
24
|
-
raise CoercionError, "#{input.inspect} is not nil"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
11
|
# @param [#to_str, Object] input
|
29
12
|
#
|
30
13
|
# @return [Date, Object]
|
@@ -14,6 +14,23 @@ module Dry
|
|
14
14
|
module JSON
|
15
15
|
extend Coercions
|
16
16
|
|
17
|
+
# @param [Object] input
|
18
|
+
#
|
19
|
+
# @return [nil] if the input is nil
|
20
|
+
#
|
21
|
+
# @raise CoercionError
|
22
|
+
#
|
23
|
+
# @api public
|
24
|
+
def self.to_nil(input, &_block)
|
25
|
+
if input.nil?
|
26
|
+
nil
|
27
|
+
elsif block_given?
|
28
|
+
yield
|
29
|
+
else
|
30
|
+
raise CoercionError, "#{input.inspect} is not nil"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
17
34
|
# @param [#to_d, Object] input
|
18
35
|
#
|
19
36
|
# @return [BigDecimal,nil]
|
@@ -18,6 +18,23 @@ module Dry
|
|
18
18
|
|
19
19
|
extend Coercions
|
20
20
|
|
21
|
+
# @param [Object] input
|
22
|
+
#
|
23
|
+
# @return [nil] if the input is an empty string or nil
|
24
|
+
#
|
25
|
+
# @raise CoercionError
|
26
|
+
#
|
27
|
+
# @api public
|
28
|
+
def self.to_nil(input, &_block)
|
29
|
+
if input.nil? || empty_str?(input)
|
30
|
+
nil
|
31
|
+
elsif block_given?
|
32
|
+
yield
|
33
|
+
else
|
34
|
+
raise CoercionError, "#{input.inspect} is not nil"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
21
38
|
# @param [String, Object] input
|
22
39
|
#
|
23
40
|
# @return [Boolean,Object]
|
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.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|