dry-initializer 3.0.0 → 3.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 +35 -0
- data/dry-initializer.gemspec +1 -1
- data/lib/dry/initializer/dispatchers/build_nested_type.rb +4 -3
- data/spec/type_constraint_spec.rb +2 -2
- 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: e17a987f9500b55fd7bf3c60caa5e8ce5c4c26cb78b94f339b62a63bdeb5a9e3
|
4
|
+
data.tar.gz: 362138efc7974312bf747f060c7af4d4117e6b8c7648849998c1aefb39d14b1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc4416e43fce6418f4708f5d7fc6753096009e9f2087f334bc11a2edeb44b3f9099d6d53ad9969d7e38ffefa524031c0e95fd4c7cb277ff7fed1a9ff63ebad5b
|
7
|
+
data.tar.gz: a2745ea32279c9e6bd9a964b0cef5e876bf3f02afd604b4193e6223d629fc1ca6ee8fd22cf1543d652b9ff5548b3bb9a7fc28c7a06f4eeb04cf233b4ccf451de
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,40 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
+
## [3.0.1] [2019-04-15]
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Usage of underscored names of `option`-s and `param`-s (nepalez)
|
13
|
+
|
14
|
+
You can use any sequence of underscores except for in nested types.
|
15
|
+
In nested types single underscores can be used to split alphanumeric
|
16
|
+
parts only.
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
class Test
|
20
|
+
extend Dry::Initializer
|
21
|
+
|
22
|
+
# Proper usage
|
23
|
+
option :foo_bar do
|
24
|
+
option :__foo__, proc(&:to_s)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Improper usage
|
29
|
+
option :__foo__ do
|
30
|
+
# ...
|
31
|
+
end
|
32
|
+
|
33
|
+
option :foo__bar do
|
34
|
+
# ...
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
This restriction is necessary because we constantize option/param names
|
40
|
+
when defining nested structs.
|
41
|
+
|
8
42
|
## [3.0.0] [2019-04-14]
|
9
43
|
|
10
44
|
### Added
|
@@ -846,3 +880,4 @@ First public release
|
|
846
880
|
[2.6.0]: https://github.com/dry-rb/dry-initializer/compare/v2.4.0...v2.5.0
|
847
881
|
[2.6.0]: https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v2.6.0
|
848
882
|
[3.0.0]: https://github.com/dry-rb/dry-initializer/compare/v2.5.0...v3.0.0
|
883
|
+
[3.0.1]: https://github.com/dry-rb/dry-initializer/compare/v3.0.0...v3.0.1
|
data/dry-initializer.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "dry-initializer"
|
3
|
-
gem.version = "3.0.
|
3
|
+
gem.version = "3.0.1"
|
4
4
|
gem.author = ["Vladimir Kochnev (marshall-lee)", "Andrew Kozin (nepalez)"]
|
5
5
|
gem.email = "andrew.kozin@gmail.com"
|
6
6
|
gem.homepage = "https://github.com/dry-rb/dry-initializer"
|
@@ -13,7 +13,7 @@ module Dry::Initializer::Dispatchers::BuildNestedType
|
|
13
13
|
# rubocop: disable Metrics/ParameterLists
|
14
14
|
def call(parent:, source:, target:, type: nil, block: nil, **options)
|
15
15
|
check_certainty!(source, type, block)
|
16
|
-
check_name!(target)
|
16
|
+
check_name!(target, block)
|
17
17
|
type ||= build_nested_type(parent, target, block)
|
18
18
|
{ parent: parent, source: source, target: target, type: type, **options }
|
19
19
|
end
|
@@ -22,8 +22,8 @@ module Dry::Initializer::Dispatchers::BuildNestedType
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def check_certainty!(source, type, block)
|
25
|
-
return unless type
|
26
25
|
return unless block
|
26
|
+
return unless type
|
27
27
|
|
28
28
|
raise ArgumentError, <<~MESSAGE
|
29
29
|
You should define coercer of values of argument '#{source}'
|
@@ -31,7 +31,8 @@ module Dry::Initializer::Dispatchers::BuildNestedType
|
|
31
31
|
MESSAGE
|
32
32
|
end
|
33
33
|
|
34
|
-
def check_name!(name)
|
34
|
+
def check_name!(name, block)
|
35
|
+
return unless block
|
35
36
|
return unless name[/^_|__|_$/]
|
36
37
|
|
37
38
|
raise ArgumentError, <<~MESSAGE
|
@@ -5,14 +5,14 @@ describe "type constraint" do
|
|
5
5
|
before do
|
6
6
|
class Test::Foo
|
7
7
|
extend Dry::Initializer
|
8
|
-
param :
|
8
|
+
param :__foo__, proc(&:to_s), optional: true
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
subject { Test::Foo.new :foo }
|
13
13
|
|
14
14
|
it "coerces a value" do
|
15
|
-
expect(subject.
|
15
|
+
expect(subject.__foo__).to eq "foo"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-initializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Kochnev (marshall-lee)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-04-
|
12
|
+
date: 2019-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|