dry-initializer 2.3.0 → 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.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +10 -21
  3. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +10 -0
  4. data/.github/ISSUE_TEMPLATE/---bug-report.md +34 -0
  5. data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
  6. data/.github/workflows/custom_ci.yml +74 -0
  7. data/.github/workflows/docsite.yml +34 -0
  8. data/.github/workflows/sync_configs.yml +34 -0
  9. data/.gitignore +2 -0
  10. data/.rspec +2 -2
  11. data/.rubocop.yml +65 -27
  12. data/CHANGELOG.md +160 -13
  13. data/CODE_OF_CONDUCT.md +13 -0
  14. data/CONTRIBUTING.md +29 -0
  15. data/Gemfile +26 -17
  16. data/LICENSE +20 -0
  17. data/README.md +13 -15
  18. data/docsite/source/attributes.html.md +106 -0
  19. data/docsite/source/container-version.html.md +39 -0
  20. data/docsite/source/index.html.md +43 -0
  21. data/docsite/source/inheritance.html.md +43 -0
  22. data/docsite/source/optionals-and-defaults.html.md +130 -0
  23. data/docsite/source/options-tolerance.html.md +27 -0
  24. data/docsite/source/params-and-options.html.md +74 -0
  25. data/docsite/source/rails-support.html.md +101 -0
  26. data/docsite/source/readers.html.md +43 -0
  27. data/docsite/source/skip-undefined.html.md +59 -0
  28. data/docsite/source/type-constraints.html.md +160 -0
  29. data/dry-initializer.gemspec +3 -3
  30. data/lib/dry/initializer.rb +11 -9
  31. data/lib/dry/initializer/builders/attribute.rb +4 -4
  32. data/lib/dry/initializer/builders/reader.rb +1 -1
  33. data/lib/dry/initializer/config.rb +22 -11
  34. data/lib/dry/initializer/definition.rb +11 -62
  35. data/lib/dry/initializer/dispatchers.rb +112 -0
  36. data/lib/dry/initializer/dispatchers/build_nested_type.rb +59 -0
  37. data/lib/dry/initializer/dispatchers/check_type.rb +43 -0
  38. data/lib/dry/initializer/dispatchers/prepare_default.rb +40 -0
  39. data/lib/dry/initializer/dispatchers/prepare_ivar.rb +12 -0
  40. data/lib/dry/initializer/dispatchers/prepare_optional.rb +13 -0
  41. data/lib/dry/initializer/dispatchers/prepare_reader.rb +30 -0
  42. data/lib/dry/initializer/dispatchers/prepare_source.rb +28 -0
  43. data/lib/dry/initializer/dispatchers/prepare_target.rb +44 -0
  44. data/lib/dry/initializer/dispatchers/unwrap_type.rb +22 -0
  45. data/lib/dry/initializer/dispatchers/wrap_type.rb +27 -0
  46. data/lib/dry/initializer/mixin/root.rb +1 -0
  47. data/lib/dry/initializer/struct.rb +39 -0
  48. data/lib/dry/initializer/undefined.rb +2 -0
  49. data/spec/coercion_of_nil_spec.rb +25 -0
  50. data/spec/custom_dispatchers_spec.rb +35 -0
  51. data/spec/definition_spec.rb +6 -2
  52. data/spec/list_type_spec.rb +32 -0
  53. data/spec/nested_type_spec.rb +48 -0
  54. data/spec/spec_helper.rb +9 -1
  55. data/spec/type_argument_spec.rb +2 -2
  56. data/spec/type_constraint_spec.rb +6 -6
  57. data/spec/value_coercion_via_dry_types_spec.rb +1 -1
  58. metadata +48 -9
  59. data/.travis.yml +0 -24
@@ -1,7 +1,15 @@
1
+ if ENV['COVERAGE'] == 'true'
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter '/spec/'
5
+ end
6
+ end
7
+
1
8
  require "dry/initializer"
9
+
2
10
  begin
3
11
  require "pry"
4
- rescue
12
+ rescue LoadError
5
13
  nil
6
14
  end
7
15
 
@@ -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 TypeError, /1/
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 TypeError, /2/
24
+ expect { subject }.to raise_error Dry::Types::ConstraintError, /2/
25
25
  end
26
26
  end
27
27
 
@@ -5,14 +5,14 @@ describe "type constraint" do
5
5
  before do
6
6
  class Test::Foo
7
7
  extend Dry::Initializer
8
- param :foo, proc(&:to_s), optional: true
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.foo).to eq "foo"
15
+ expect(subject.__foo__).to eq "foo"
16
16
  end
17
17
  end
18
18
 
@@ -42,8 +42,8 @@ describe "type constraint" do
42
42
  context "in case of mismatch" do
43
43
  subject { Test::Foo.new 1 }
44
44
 
45
- it "raises TypeError" do
46
- expect { subject }.to raise_error TypeError, /1/
45
+ it "raises ArgumentError" do
46
+ expect { subject }.to raise_error Dry::Types::ConstraintError, /1/
47
47
  end
48
48
  end
49
49
 
@@ -66,13 +66,13 @@ describe "type constraint" do
66
66
  end
67
67
 
68
68
  context "by invalid constraint" do
69
- it "raises TypeError" do
69
+ it "raises ArgumentError" do
70
70
  expect do
71
71
  class Test::Foo
72
72
  extend Dry::Initializer
73
73
  param :foo, type: String
74
74
  end
75
- end.to raise_error(TypeError)
75
+ end.to raise_error(ArgumentError)
76
76
  end
77
77
  end
78
78
  end
@@ -3,7 +3,7 @@ require "dry-types"
3
3
  describe "value coercion via dry-types" do
4
4
  before do
5
5
  module Test::Types
6
- include Dry::Types.module
6
+ include Dry.Types
7
7
  end
8
8
 
9
9
  class Test::Foo
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: 2.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: 2017-09-19 00:00:00.000000000 Z
12
+ date: 2019-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -59,30 +59,39 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.42'
62
+ version: 0.49.0
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.42'
69
+ version: 0.49.0
70
70
  description:
71
71
  email: andrew.kozin@gmail.com
72
72
  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
@@ -102,18 +122,35 @@ files:
102
122
  - lib/dry/initializer/builders/signature.rb
103
123
  - lib/dry/initializer/config.rb
104
124
  - lib/dry/initializer/definition.rb
125
+ - lib/dry/initializer/dispatchers.rb
126
+ - lib/dry/initializer/dispatchers/build_nested_type.rb
127
+ - lib/dry/initializer/dispatchers/check_type.rb
128
+ - lib/dry/initializer/dispatchers/prepare_default.rb
129
+ - lib/dry/initializer/dispatchers/prepare_ivar.rb
130
+ - lib/dry/initializer/dispatchers/prepare_optional.rb
131
+ - lib/dry/initializer/dispatchers/prepare_reader.rb
132
+ - lib/dry/initializer/dispatchers/prepare_source.rb
133
+ - lib/dry/initializer/dispatchers/prepare_target.rb
134
+ - lib/dry/initializer/dispatchers/unwrap_type.rb
135
+ - lib/dry/initializer/dispatchers/wrap_type.rb
105
136
  - lib/dry/initializer/dsl.rb
106
137
  - lib/dry/initializer/mixin.rb
107
138
  - lib/dry/initializer/mixin/local.rb
108
139
  - lib/dry/initializer/mixin/root.rb
140
+ - lib/dry/initializer/struct.rb
141
+ - lib/dry/initializer/undefined.rb
109
142
  - lib/tasks/benchmark.rake
110
143
  - lib/tasks/profile.rake
111
144
  - spec/attributes_spec.rb
145
+ - spec/coercion_of_nil_spec.rb
146
+ - spec/custom_dispatchers_spec.rb
112
147
  - spec/custom_initializer_spec.rb
113
148
  - spec/default_values_spec.rb
114
149
  - spec/definition_spec.rb
115
150
  - spec/invalid_default_spec.rb
151
+ - spec/list_type_spec.rb
116
152
  - spec/missed_default_spec.rb
153
+ - spec/nested_type_spec.rb
117
154
  - spec/optional_spec.rb
118
155
  - spec/options_tolerance_spec.rb
119
156
  - spec/public_attributes_utility_spec.rb
@@ -125,7 +162,7 @@ files:
125
162
  - spec/type_argument_spec.rb
126
163
  - spec/type_constraint_spec.rb
127
164
  - spec/value_coercion_via_dry_types_spec.rb
128
- homepage: https://github.com/dryrb/dry-initializer
165
+ homepage: https://github.com/dry-rb/dry-initializer
129
166
  licenses:
130
167
  - MIT
131
168
  metadata: {}
@@ -144,18 +181,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
181
  - !ruby/object:Gem::Version
145
182
  version: '0'
146
183
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.6.13
184
+ rubygems_version: 3.0.6
149
185
  signing_key:
150
186
  specification_version: 4
151
187
  summary: DSL for declaring params and options of the initializer
152
188
  test_files:
153
189
  - spec/attributes_spec.rb
190
+ - spec/coercion_of_nil_spec.rb
191
+ - spec/custom_dispatchers_spec.rb
154
192
  - spec/custom_initializer_spec.rb
155
193
  - spec/default_values_spec.rb
156
194
  - spec/definition_spec.rb
157
195
  - spec/invalid_default_spec.rb
196
+ - spec/list_type_spec.rb
158
197
  - spec/missed_default_spec.rb
198
+ - spec/nested_type_spec.rb
159
199
  - spec/optional_spec.rb
160
200
  - spec/options_tolerance_spec.rb
161
201
  - spec/public_attributes_utility_spec.rb
@@ -167,4 +207,3 @@ test_files:
167
207
  - spec/type_argument_spec.rb
168
208
  - spec/type_constraint_spec.rb
169
209
  - spec/value_coercion_via_dry_types_spec.rb
170
- has_rdoc:
@@ -1,24 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- bundler_args: --without benchmarks tools
6
- script:
7
- - bundle exec rake spec
8
- rvm:
9
- - 2.3.0
10
- - 2.4.0
11
- - jruby-9000
12
- - rbx-3
13
- - ruby-head
14
- env:
15
- global:
16
- - JRUBY_OPTS='--dev -J-Xmx1024M'
17
- matrix:
18
- allow_failures:
19
- - rvm: rbx-3
20
- - rvm: ruby-head
21
- - rvm: jruby-head
22
- include:
23
- - rvm: jruby-head
24
- before_install: gem install bundler --no-ri --no-rdoc