dry-initializer 3.0.1 → 3.0.2
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/.codeclimate.yml +10 -21
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
- data/.github/ISSUE_TEMPLATE/---bug-report.md +34 -0
- data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
- data/.github/workflows/custom_ci.yml +74 -0
- data/.github/workflows/docsite.yml +34 -0
- data/.github/workflows/sync_configs.yml +34 -0
- data/.gitignore +2 -0
- data/.rspec +2 -2
- data/.rubocop.yml +65 -27
- data/CHANGELOG.md +10 -3
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +29 -0
- data/Gemfile +26 -17
- data/LICENSE +20 -0
- data/README.md +11 -12
- data/docsite/source/attributes.html.md +106 -0
- data/docsite/source/container-version.html.md +39 -0
- data/docsite/source/index.html.md +43 -0
- data/docsite/source/inheritance.html.md +43 -0
- data/docsite/source/optionals-and-defaults.html.md +130 -0
- data/docsite/source/options-tolerance.html.md +27 -0
- data/docsite/source/params-and-options.html.md +74 -0
- data/docsite/source/rails-support.html.md +101 -0
- data/docsite/source/readers.html.md +43 -0
- data/docsite/source/skip-undefined.html.md +59 -0
- data/docsite/source/type-constraints.html.md +160 -0
- data/dry-initializer.gemspec +1 -1
- data/lib/dry/initializer/config.rb +5 -5
- data/lib/dry/initializer/dispatchers.rb +2 -2
- data/lib/dry/initializer/mixin/root.rb +1 -0
- data/lib/dry/initializer/struct.rb +2 -3
- data/spec/nested_type_spec.rb +4 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/type_argument_spec.rb +2 -2
- data/spec/type_constraint_spec.rb +1 -1
- data/spec/value_coercion_via_dry_types_spec.rb +1 -1
- metadata +24 -4
- data/.travis.yml +0 -28
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.2"
|
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"
|
@@ -58,7 +58,7 @@ module Dry::Initializer
|
|
58
58
|
# @option opts [true, false, :protected, :public, :private] :reader
|
59
59
|
# @return [self] itself
|
60
60
|
def param(name, type = nil, **opts, &block)
|
61
|
-
add_definition(false, name, type, block, opts)
|
61
|
+
add_definition(false, name, type, block, **opts)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Adds or redefines an option of [#dry_initializer]
|
@@ -68,7 +68,7 @@ module Dry::Initializer
|
|
68
68
|
# @return (see #param)
|
69
69
|
#
|
70
70
|
def option(name, type = nil, **opts, &block)
|
71
|
-
add_definition(true, name, type, block, opts)
|
71
|
+
add_definition(true, name, type, block, **opts)
|
72
72
|
end
|
73
73
|
|
74
74
|
# The hash of public attributes for an instance of the [#extended_class]
|
@@ -142,11 +142,11 @@ module Dry::Initializer
|
|
142
142
|
source: name,
|
143
143
|
type: type,
|
144
144
|
block: block,
|
145
|
-
**opts
|
145
|
+
**opts
|
146
146
|
}
|
147
147
|
|
148
|
-
options = Dispatchers.call(opts)
|
149
|
-
definition = Definition.new(options)
|
148
|
+
options = Dispatchers.call(**opts)
|
149
|
+
definition = Definition.new(**options)
|
150
150
|
definitions[definition.source] = definition
|
151
151
|
finalize
|
152
152
|
mixin.class_eval definition.code
|
@@ -85,8 +85,8 @@ module Dry::Initializer::Dispatchers
|
|
85
85
|
# @return [Hash<Symbol, Objct>] normalized set of options
|
86
86
|
#
|
87
87
|
def call(**options)
|
88
|
-
options = { null: null }
|
89
|
-
pipeline.reduce(options) { |opts, dispatcher| dispatcher.call(opts) }
|
88
|
+
options = { null: null, **options }
|
89
|
+
pipeline.reduce(options) { |opts, dispatcher| dispatcher.call(**opts) }
|
90
90
|
end
|
91
91
|
|
92
92
|
private
|
@@ -8,7 +8,7 @@ class Dry::Initializer::Struct
|
|
8
8
|
undef_method :param
|
9
9
|
|
10
10
|
def new(options)
|
11
|
-
super
|
11
|
+
super(**Hash(options).each_with_object({}) { |(k, v), h| h[k.to_sym] = v })
|
12
12
|
end
|
13
13
|
alias call new
|
14
14
|
end
|
@@ -22,8 +22,7 @@ class Dry::Initializer::Struct
|
|
22
22
|
.class
|
23
23
|
.dry_initializer
|
24
24
|
.attributes(self)
|
25
|
-
.
|
26
|
-
.stringify_keys
|
25
|
+
.each_with_object({}) { |(k, v), h| h[k.to_s] = __hashify(v) }
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
data/spec/nested_type_spec.rb
CHANGED
@@ -18,6 +18,10 @@ describe "nested type argument" do
|
|
18
18
|
it "builds the type" do
|
19
19
|
expect(subject.x.y.z).to eq "42"
|
20
20
|
end
|
21
|
+
|
22
|
+
it "converts the nested type to hash" do
|
23
|
+
expect(subject.x.to_h).to eq("y" => { "z" => "42" })
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
context "with nested and wrapped definitions" do
|
data/spec/spec_helper.rb
CHANGED
data/spec/type_argument_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe "type argument" do
|
|
13
13
|
subject { Test::Foo.new 1, bar: "2" }
|
14
14
|
|
15
15
|
it "raises TypeError" do
|
16
|
-
expect { subject }.to raise_error
|
16
|
+
expect { subject }.to raise_error Dry::Types::ConstraintError, /1/
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -21,7 +21,7 @@ describe "type argument" do
|
|
21
21
|
subject { Test::Foo.new "1", bar: 2 }
|
22
22
|
|
23
23
|
it "raises TypeError" do
|
24
|
-
expect { subject }.to raise_error
|
24
|
+
expect { subject }.to raise_error Dry::Types::ConstraintError, /2/
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
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.2
|
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-
|
12
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -73,16 +73,25 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files:
|
75
75
|
- README.md
|
76
|
+
- LICENSE
|
76
77
|
- CHANGELOG.md
|
77
78
|
files:
|
78
79
|
- ".codeclimate.yml"
|
80
|
+
- ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
|
81
|
+
- ".github/ISSUE_TEMPLATE/---bug-report.md"
|
82
|
+
- ".github/ISSUE_TEMPLATE/---feature-request.md"
|
83
|
+
- ".github/workflows/custom_ci.yml"
|
84
|
+
- ".github/workflows/docsite.yml"
|
85
|
+
- ".github/workflows/sync_configs.yml"
|
79
86
|
- ".gitignore"
|
80
87
|
- ".rspec"
|
81
88
|
- ".rubocop.yml"
|
82
|
-
- ".travis.yml"
|
83
89
|
- CHANGELOG.md
|
90
|
+
- CODE_OF_CONDUCT.md
|
91
|
+
- CONTRIBUTING.md
|
84
92
|
- Gemfile
|
85
93
|
- Guardfile
|
94
|
+
- LICENSE
|
86
95
|
- LICENSE.txt
|
87
96
|
- README.md
|
88
97
|
- Rakefile
|
@@ -92,6 +101,17 @@ files:
|
|
92
101
|
- benchmarks/with_coercion.rb
|
93
102
|
- benchmarks/with_defaults.rb
|
94
103
|
- benchmarks/with_defaults_and_coercion.rb
|
104
|
+
- docsite/source/attributes.html.md
|
105
|
+
- docsite/source/container-version.html.md
|
106
|
+
- docsite/source/index.html.md
|
107
|
+
- docsite/source/inheritance.html.md
|
108
|
+
- docsite/source/optionals-and-defaults.html.md
|
109
|
+
- docsite/source/options-tolerance.html.md
|
110
|
+
- docsite/source/params-and-options.html.md
|
111
|
+
- docsite/source/rails-support.html.md
|
112
|
+
- docsite/source/readers.html.md
|
113
|
+
- docsite/source/skip-undefined.html.md
|
114
|
+
- docsite/source/type-constraints.html.md
|
95
115
|
- dry-initializer.gemspec
|
96
116
|
- lib/dry-initializer.rb
|
97
117
|
- lib/dry/initializer.rb
|
@@ -161,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
181
|
- !ruby/object:Gem::Version
|
162
182
|
version: '0'
|
163
183
|
requirements: []
|
164
|
-
rubygems_version: 3.0.
|
184
|
+
rubygems_version: 3.0.6
|
165
185
|
signing_key:
|
166
186
|
specification_version: 4
|
167
187
|
summary: DSL for declaring params and options of the initializer
|
data/.travis.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
bundler_args: --without benchmarks tools
|
5
|
-
script:
|
6
|
-
- bundle exec rake spec
|
7
|
-
rvm:
|
8
|
-
- 2.3.8
|
9
|
-
- 2.4.6
|
10
|
-
- 2.5.5
|
11
|
-
- 2.6.2
|
12
|
-
- jruby-9.2.7.0
|
13
|
-
- jruby-9000
|
14
|
-
- rbx-3
|
15
|
-
- ruby-head
|
16
|
-
- truffleruby
|
17
|
-
env:
|
18
|
-
global:
|
19
|
-
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
20
|
-
matrix:
|
21
|
-
allow_failures:
|
22
|
-
- rvm: rbx-3
|
23
|
-
- rvm: ruby-head
|
24
|
-
- rvm: jruby-head
|
25
|
-
- rvm: truffleruby
|
26
|
-
include:
|
27
|
-
- rvm: jruby-head
|
28
|
-
before_install: gem install bundler --no-document
|