dry-initializer 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/---bug-report.md +1 -5
- data/.github/workflows/custom_ci.yml +31 -47
- data/.github/workflows/sync_configs.yml +29 -7
- data/.rspec +1 -1
- data/.rubocop.yml +19 -6
- data/CHANGELOG.md +6 -0
- data/Gemfile +27 -29
- data/Gemfile.devtools +16 -0
- data/Guardfile +3 -3
- data/LICENSE +1 -1
- data/README.md +17 -77
- data/Rakefile +4 -4
- data/benchmarks/compare_several_defaults.rb +27 -27
- data/benchmarks/plain_options.rb +14 -14
- data/benchmarks/plain_params.rb +22 -22
- data/benchmarks/with_coercion.rb +14 -14
- data/benchmarks/with_defaults.rb +17 -17
- data/benchmarks/with_defaults_and_coercion.rb +14 -14
- data/bin/.gitkeep +0 -0
- data/dry-initializer.gemspec +13 -13
- data/lib/dry-initializer.rb +1 -1
- data/lib/dry/initializer.rb +9 -9
- data/lib/dry/initializer/builders.rb +2 -2
- data/lib/dry/initializer/builders/attribute.rb +12 -7
- data/lib/dry/initializer/builders/initializer.rb +9 -13
- data/lib/dry/initializer/builders/reader.rb +3 -1
- data/lib/dry/initializer/builders/signature.rb +3 -3
- data/lib/dry/initializer/config.rb +6 -4
- data/lib/dry/initializer/definition.rb +9 -9
- data/lib/dry/initializer/dispatchers.rb +10 -10
- data/lib/dry/initializer/dispatchers/prepare_default.rb +2 -2
- data/lib/dry/initializer/dispatchers/prepare_ivar.rb +1 -1
- data/lib/dry/initializer/dispatchers/prepare_reader.rb +3 -3
- data/lib/dry/initializer/dispatchers/wrap_type.rb +1 -0
- data/lib/dry/initializer/mixin.rb +4 -4
- data/lib/dry/initializer/version.rb +5 -0
- data/lib/tasks/benchmark.rake +13 -13
- data/lib/tasks/profile.rake +16 -16
- data/project.yml +2 -0
- data/spec/attributes_spec.rb +7 -7
- data/spec/coercion_of_nil_spec.rb +3 -3
- data/spec/custom_dispatchers_spec.rb +6 -6
- data/spec/custom_initializer_spec.rb +2 -2
- data/spec/default_values_spec.rb +9 -9
- data/spec/definition_spec.rb +10 -10
- data/spec/invalid_default_spec.rb +2 -2
- data/spec/list_type_spec.rb +8 -8
- data/spec/missed_default_spec.rb +2 -2
- data/spec/nested_type_spec.rb +10 -10
- data/spec/optional_spec.rb +16 -16
- data/spec/options_tolerance_spec.rb +2 -2
- data/spec/public_attributes_utility_spec.rb +5 -5
- data/spec/reader_spec.rb +13 -13
- data/spec/repetitive_definitions_spec.rb +9 -9
- data/spec/several_assignments_spec.rb +9 -9
- data/spec/spec_helper.rb +3 -8
- data/spec/subclassing_spec.rb +5 -5
- data/spec/support/coverage.rb +7 -0
- data/spec/support/warnings.rb +7 -0
- data/spec/type_argument_spec.rb +13 -13
- data/spec/type_constraint_spec.rb +44 -26
- data/spec/value_coercion_via_dry_types_spec.rb +7 -7
- metadata +11 -31
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'dry-types'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'value coercion via dry-types' do
|
4
4
|
before do
|
5
5
|
module Test::Types
|
6
6
|
include Dry.Types
|
@@ -10,18 +10,18 @@ describe "value coercion via dry-types" do
|
|
10
10
|
extend Dry::Initializer
|
11
11
|
|
12
12
|
param :foo, type: Test::Types::Coercible::String
|
13
|
-
option :bar, proc(&:to_i), default: proc {
|
13
|
+
option :bar, proc(&:to_i), default: proc { '16' }
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
subject = Test::Foo.new :foo, bar:
|
17
|
+
it 'coerces assigned values' do
|
18
|
+
subject = Test::Foo.new :foo, bar: '13'
|
19
19
|
|
20
|
-
expect(subject.foo).to eql
|
20
|
+
expect(subject.foo).to eql 'foo'
|
21
21
|
expect(subject.bar).to eql 13
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'coerces defaults as well' do
|
25
25
|
subject = Test::Foo.new :foo
|
26
26
|
|
27
27
|
expect(subject.bar).to eql 16
|
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.3
|
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:
|
12
|
+
date: 2020-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -39,34 +39,6 @@ dependencies:
|
|
39
39
|
- - ">"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '10'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: dry-types
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 0.5.1
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 0.5.1
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rubocop
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.49.0
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.49.0
|
70
42
|
description:
|
71
43
|
email: andrew.kozin@gmail.com
|
72
44
|
executables: []
|
@@ -90,6 +62,7 @@ files:
|
|
90
62
|
- CODE_OF_CONDUCT.md
|
91
63
|
- CONTRIBUTING.md
|
92
64
|
- Gemfile
|
65
|
+
- Gemfile.devtools
|
93
66
|
- Guardfile
|
94
67
|
- LICENSE
|
95
68
|
- LICENSE.txt
|
@@ -101,6 +74,7 @@ files:
|
|
101
74
|
- benchmarks/with_coercion.rb
|
102
75
|
- benchmarks/with_defaults.rb
|
103
76
|
- benchmarks/with_defaults_and_coercion.rb
|
77
|
+
- bin/.gitkeep
|
104
78
|
- docsite/source/attributes.html.md
|
105
79
|
- docsite/source/container-version.html.md
|
106
80
|
- docsite/source/index.html.md
|
@@ -139,8 +113,10 @@ files:
|
|
139
113
|
- lib/dry/initializer/mixin/root.rb
|
140
114
|
- lib/dry/initializer/struct.rb
|
141
115
|
- lib/dry/initializer/undefined.rb
|
116
|
+
- lib/dry/initializer/version.rb
|
142
117
|
- lib/tasks/benchmark.rake
|
143
118
|
- lib/tasks/profile.rake
|
119
|
+
- project.yml
|
144
120
|
- spec/attributes_spec.rb
|
145
121
|
- spec/coercion_of_nil_spec.rb
|
146
122
|
- spec/custom_dispatchers_spec.rb
|
@@ -159,6 +135,8 @@ files:
|
|
159
135
|
- spec/several_assignments_spec.rb
|
160
136
|
- spec/spec_helper.rb
|
161
137
|
- spec/subclassing_spec.rb
|
138
|
+
- spec/support/coverage.rb
|
139
|
+
- spec/support/warnings.rb
|
162
140
|
- spec/type_argument_spec.rb
|
163
141
|
- spec/type_constraint_spec.rb
|
164
142
|
- spec/value_coercion_via_dry_types_spec.rb
|
@@ -181,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
159
|
- !ruby/object:Gem::Version
|
182
160
|
version: '0'
|
183
161
|
requirements: []
|
184
|
-
rubygems_version: 3.0.
|
162
|
+
rubygems_version: 3.0.3
|
185
163
|
signing_key:
|
186
164
|
specification_version: 4
|
187
165
|
summary: DSL for declaring params and options of the initializer
|
@@ -204,6 +182,8 @@ test_files:
|
|
204
182
|
- spec/several_assignments_spec.rb
|
205
183
|
- spec/spec_helper.rb
|
206
184
|
- spec/subclassing_spec.rb
|
185
|
+
- spec/support/coverage.rb
|
186
|
+
- spec/support/warnings.rb
|
207
187
|
- spec/type_argument_spec.rb
|
208
188
|
- spec/type_constraint_spec.rb
|
209
189
|
- spec/value_coercion_via_dry_types_spec.rb
|