dry-initializer 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +234 -242
  3. data/dry-initializer.gemspec +28 -15
  4. data/lib/dry/initializer/builders/attribute.rb +1 -1
  5. data/lib/dry/initializer/version.rb +1 -1
  6. metadata +24 -104
  7. data/.codeclimate.yml +0 -12
  8. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
  9. data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
  10. data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
  11. data/.github/workflows/custom_ci.yml +0 -58
  12. data/.github/workflows/docsite.yml +0 -34
  13. data/.github/workflows/sync_configs.yml +0 -56
  14. data/.gitignore +0 -12
  15. data/.rspec +0 -4
  16. data/.rubocop.yml +0 -102
  17. data/CODE_OF_CONDUCT.md +0 -13
  18. data/CONTRIBUTING.md +0 -29
  19. data/Gemfile +0 -36
  20. data/Gemfile.devtools +0 -16
  21. data/Guardfile +0 -5
  22. data/LICENSE.txt +0 -21
  23. data/Rakefile +0 -8
  24. data/benchmarks/compare_several_defaults.rb +0 -82
  25. data/benchmarks/plain_options.rb +0 -63
  26. data/benchmarks/plain_params.rb +0 -84
  27. data/benchmarks/with_coercion.rb +0 -71
  28. data/benchmarks/with_defaults.rb +0 -66
  29. data/benchmarks/with_defaults_and_coercion.rb +0 -59
  30. data/bin/.gitkeep +0 -0
  31. data/docsite/source/attributes.html.md +0 -106
  32. data/docsite/source/container-version.html.md +0 -39
  33. data/docsite/source/index.html.md +0 -43
  34. data/docsite/source/inheritance.html.md +0 -43
  35. data/docsite/source/optionals-and-defaults.html.md +0 -130
  36. data/docsite/source/options-tolerance.html.md +0 -27
  37. data/docsite/source/params-and-options.html.md +0 -74
  38. data/docsite/source/rails-support.html.md +0 -101
  39. data/docsite/source/readers.html.md +0 -43
  40. data/docsite/source/skip-undefined.html.md +0 -59
  41. data/docsite/source/type-constraints.html.md +0 -160
  42. data/project.yml +0 -2
  43. data/spec/attributes_spec.rb +0 -38
  44. data/spec/coercion_of_nil_spec.rb +0 -25
  45. data/spec/custom_dispatchers_spec.rb +0 -35
  46. data/spec/custom_initializer_spec.rb +0 -30
  47. data/spec/default_values_spec.rb +0 -83
  48. data/spec/definition_spec.rb +0 -111
  49. data/spec/invalid_default_spec.rb +0 -13
  50. data/spec/list_type_spec.rb +0 -32
  51. data/spec/missed_default_spec.rb +0 -14
  52. data/spec/nested_type_spec.rb +0 -48
  53. data/spec/optional_spec.rb +0 -71
  54. data/spec/options_tolerance_spec.rb +0 -11
  55. data/spec/public_attributes_utility_spec.rb +0 -22
  56. data/spec/reader_spec.rb +0 -87
  57. data/spec/repetitive_definitions_spec.rb +0 -69
  58. data/spec/several_assignments_spec.rb +0 -41
  59. data/spec/spec_helper.rb +0 -24
  60. data/spec/subclassing_spec.rb +0 -49
  61. data/spec/support/coverage.rb +0 -7
  62. data/spec/support/warnings.rb +0 -7
  63. data/spec/type_argument_spec.rb +0 -35
  64. data/spec/type_constraint_spec.rb +0 -96
  65. data/spec/value_coercion_via_dry_types_spec.rb +0 -29
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /*.gem
11
-
12
- .vscode
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --order random
4
- --warnings
@@ -1,102 +0,0 @@
1
- # this file is managed by dry-rb/devtools project
2
-
3
- AllCops:
4
- TargetRubyVersion: 2.4
5
-
6
- Style/EachWithObject:
7
- Enabled: false
8
-
9
- Style/StringLiterals:
10
- Enabled: true
11
- EnforcedStyle: single_quotes
12
-
13
- Style/ParallelAssignment:
14
- Enabled: false
15
-
16
- Style/Alias:
17
- Enabled: true
18
- EnforcedStyle: prefer_alias_method
19
-
20
- Style/LambdaCall:
21
- Enabled: false
22
-
23
- Style/StabbyLambdaParentheses:
24
- Enabled: false
25
-
26
- Style/FormatString:
27
- Enabled: false
28
-
29
- Style/Documentation:
30
- Enabled: false
31
-
32
- Layout/SpaceInLambdaLiteral:
33
- Enabled: false
34
-
35
- Layout/MultilineMethodCallIndentation:
36
- Enabled: true
37
- EnforcedStyle: indented
38
-
39
- Metrics/LineLength:
40
- Max: 100
41
-
42
- Metrics/MethodLength:
43
- Enabled: false
44
-
45
- Metrics/ClassLength:
46
- Enabled: false
47
-
48
- Metrics/BlockLength:
49
- Enabled: false
50
-
51
- Metrics/AbcSize:
52
- Max: 20
53
-
54
- Metrics/CyclomaticComplexity:
55
- Enabled: true
56
- Max: 10
57
-
58
- Lint/BooleanSymbol:
59
- Enabled: false
60
-
61
- Style/AccessModifierDeclarations:
62
- Enabled: false
63
-
64
- Style/BlockDelimiters:
65
- Enabled: false
66
-
67
- Layout/IndentFirstArrayElement:
68
- EnforcedStyle: consistent
69
-
70
- Style/ClassAndModuleChildren:
71
- Exclude:
72
- - "spec/**/*_spec.rb"
73
-
74
- Lint/HandleExceptions:
75
- Exclude:
76
- - "spec/spec_helper.rb"
77
-
78
- Naming/PredicateName:
79
- Enabled: false
80
-
81
- Naming/FileName:
82
- Exclude:
83
- - "lib/dry-*.rb"
84
-
85
- Style/SymbolArray:
86
- Exclude:
87
- - "spec/**/*_spec.rb"
88
-
89
- Style/ConditionalAssignment:
90
- Enabled: false
91
-
92
- Naming/MethodName:
93
- Enabled: false
94
-
95
- Style/AsciiComments:
96
- Enabled: false
97
-
98
- Style/DateTime:
99
- Enabled: false
100
-
101
- Style/IfUnlessModifier:
102
- Enabled: false
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)
@@ -1,29 +0,0 @@
1
- # Issue Guidelines
2
-
3
- ## Reporting bugs
4
-
5
- If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
6
-
7
- ## Reporting feature requests
8
-
9
- Report a feature request **only after discussing it first on [discourse.dry-rb.org](https://discourse.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
10
-
11
- ## Reporting questions, support requests, ideas, concerns etc.
12
-
13
- **PLEASE DON'T** - use [discourse.dry-rb.org](http://discourse.dry-rb.org) instead.
14
-
15
- # Pull Request Guidelines
16
-
17
- A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
18
-
19
- Other requirements:
20
-
21
- 1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
22
- 2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
23
- 3) Add API documentation if it's a new feature
24
- 4) Update API documentation if it changes an existing feature
25
- 5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
26
-
27
- # Asking for help
28
-
29
- If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org) or join [our chat](https://dry-rb.zulipchat.com).
data/Gemfile DELETED
@@ -1,36 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- eval_gemfile 'Gemfile.devtools'
4
-
5
- gemspec
6
-
7
- if ENV['DRY_TYPES_FROM_MASTER'].eql?('true')
8
- gem 'dry-types', github: 'dry-rb/dry-types', branch: 'master'
9
- else
10
- gem 'dry-types'
11
- end
12
-
13
- group :benchmarks do
14
- if RUBY_VERSION < '2.4'
15
- gem 'activesupport', '< 5'
16
- else
17
- gem 'activesupport'
18
- end
19
-
20
- gem 'active_attr'
21
- gem 'anima'
22
- gem 'attr_extras'
23
- gem 'benchmark-ips', '~> 2.5'
24
- gem 'concord'
25
- gem 'fast_attributes'
26
- gem 'kwattr'
27
- gem 'ruby-prof', platform: :mri
28
- gem 'value_struct'
29
- gem 'values'
30
- gem 'virtus'
31
- end
32
-
33
- group :development, :test do
34
- gem 'pry', platform: :mri
35
- gem 'pry-byebug', platform: :mri
36
- end
@@ -1,16 +0,0 @@
1
- # this file is managed by dry-rb/devtools project
2
-
3
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
-
5
- gem "ossy", github: "solnic/ossy", branch: "master", platforms: :ruby
6
-
7
- group :test do
8
- gem 'codacy-coverage', require: false, platforms: :ruby
9
- gem 'simplecov', require: false, platforms: :ruby
10
- gem 'warning'
11
- end
12
-
13
- group :tools do
14
- # this is the same version that we use on codacy
15
- gem 'rubocop', '0.71.0'
16
- end
data/Guardfile DELETED
@@ -1,5 +0,0 @@
1
- guard :rspec, cmd: 'bundle exec rspec' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^spec/(spec_helper|support)}) { 'spec' }
4
- watch(%r{^lib/.+}) { 'spec' }
5
- end
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016-2017 Andrew Kozin (nepalez), Vladimir Kochnev (marshall-lee)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new :default
6
-
7
- load 'lib/tasks/benchmark.rake'
8
- load 'lib/tasks/profile.rake'
@@ -1,82 +0,0 @@
1
- Bundler.require(:benchmarks)
2
-
3
- require 'dry-initializer'
4
- class WithoutDefaults
5
- extend Dry::Initializer
6
-
7
- param :foo
8
- param :bar
9
- param :baz
10
- end
11
-
12
- class WithOneDefault
13
- extend Dry::Initializer
14
-
15
- param :foo
16
- param :bar
17
- param :baz, default: proc { 'BAZ' }
18
- end
19
-
20
- class WithTwoDefaults
21
- extend Dry::Initializer
22
-
23
- param :foo
24
- param :bar, default: proc { 'BAR' }
25
- param :baz, default: proc { 'BAZ' }
26
- end
27
-
28
- class WithThreeDefaults
29
- extend Dry::Initializer
30
-
31
- param :foo, default: proc { 'FOO' }
32
- param :bar, default: proc { 'BAR' }
33
- param :baz, default: proc { 'BAZ' }
34
- end
35
-
36
- puts 'Benchmark for various options'
37
-
38
- Benchmark.ips do |x|
39
- x.config time: 15, warmup: 10
40
-
41
- x.report('without defaults') do
42
- WithoutDefaults.new 'FOO', 'BAR', 'BAZ'
43
- end
44
-
45
- x.report('with 0 of 1 default used') do
46
- WithOneDefault.new 'FOO', 'BAR', 'BAZ'
47
- end
48
-
49
- x.report('with 1 of 1 default used') do
50
- WithOneDefault.new 'FOO', 'BAR'
51
- end
52
-
53
- x.report('with 0 of 2 defaults used') do
54
- WithTwoDefaults.new 'FOO', 'BAR', 'BAZ'
55
- end
56
-
57
- x.report('with 1 of 2 defaults used') do
58
- WithTwoDefaults.new 'FOO', 'BAR'
59
- end
60
-
61
- x.report('with 2 of 2 defaults used') do
62
- WithTwoDefaults.new 'FOO'
63
- end
64
-
65
- x.report('with 0 of 3 defaults used') do
66
- WithThreeDefaults.new 'FOO', 'BAR', 'BAZ'
67
- end
68
-
69
- x.report('with 1 of 3 defaults used') do
70
- WithThreeDefaults.new 'FOO', 'BAR'
71
- end
72
-
73
- x.report('with 2 of 3 defaults used') do
74
- WithThreeDefaults.new 'FOO'
75
- end
76
-
77
- x.report('with 3 of 3 defaults used') do
78
- WithThreeDefaults.new
79
- end
80
-
81
- x.compare!
82
- end
@@ -1,63 +0,0 @@
1
- Bundler.require(:benchmarks)
2
-
3
- require 'dry-initializer'
4
- class DryTest
5
- extend Dry::Initializer[undefined: false]
6
-
7
- option :foo
8
- option :bar
9
- end
10
-
11
- class DryTestUndefined
12
- extend Dry::Initializer
13
-
14
- option :foo
15
- option :bar
16
- end
17
-
18
- class PlainRubyTest
19
- attr_reader :foo, :bar
20
-
21
- def initialize(options = {})
22
- @foo = options[:foo]
23
- @bar = options[:bar]
24
- end
25
- end
26
-
27
- require 'anima'
28
- class AnimaTest
29
- include Anima.new(:foo, :bar)
30
- end
31
-
32
- require 'kwattr'
33
- class KwattrTest
34
- kwattr :foo, :bar
35
- end
36
-
37
- puts 'Benchmark for instantiation with plain options'
38
-
39
- Benchmark.ips do |x|
40
- x.config time: 15, warmup: 10
41
-
42
- x.report('plain Ruby') do
43
- PlainRubyTest.new foo: 'FOO', bar: 'BAR'
44
- end
45
-
46
- x.report('dry-initializer') do
47
- DryTest.new foo: 'FOO', bar: 'BAR'
48
- end
49
-
50
- x.report('dry-initializer (with UNDEFINED)') do
51
- DryTestUndefined.new foo: 'FOO', bar: 'BAR'
52
- end
53
-
54
- x.report('anima') do
55
- AnimaTest.new foo: 'FOO', bar: 'BAR'
56
- end
57
-
58
- x.report('kwattr') do
59
- KwattrTest.new foo: 'FOO', bar: 'BAR'
60
- end
61
-
62
- x.compare!
63
- end
@@ -1,84 +0,0 @@
1
- Bundler.require(:benchmarks)
2
-
3
- require 'dry-initializer'
4
- class DryTest
5
- extend Dry::Initializer[undefined: false]
6
-
7
- param :foo
8
- param :bar
9
- end
10
-
11
- class DryTestUndefined
12
- extend Dry::Initializer
13
-
14
- param :foo
15
- param :bar
16
- end
17
-
18
- class PlainRubyTest
19
- attr_reader :foo, :bar
20
-
21
- def initialize(foo, bar)
22
- @foo = foo
23
- @bar = bar
24
- end
25
- end
26
-
27
- StructTest = Struct.new(:foo, :bar)
28
-
29
- require 'concord'
30
- class ConcordTest
31
- include Concord.new(:foo, :bar)
32
- end
33
-
34
- require 'values'
35
- ValueTest = Value.new(:foo, :bar)
36
-
37
- require 'value_struct'
38
- ValueStructTest = ValueStruct.new(:foo, :bar)
39
-
40
- require 'attr_extras'
41
- class AttrExtrasText
42
- attr_initialize :foo, :bar
43
- attr_reader :foo, :bar
44
- end
45
-
46
- puts 'Benchmark for instantiation with plain params'
47
-
48
- Benchmark.ips do |x|
49
- x.config time: 15, warmup: 10
50
-
51
- x.report('plain Ruby') do
52
- PlainRubyTest.new 'FOO', 'BAR'
53
- end
54
-
55
- x.report('Core Struct') do
56
- StructTest.new 'FOO', 'BAR'
57
- end
58
-
59
- x.report('values') do
60
- ValueTest.new 'FOO', 'BAR'
61
- end
62
-
63
- x.report('value_struct') do
64
- ValueStructTest.new 'FOO', 'BAR'
65
- end
66
-
67
- x.report('dry-initializer') do
68
- DryTest.new 'FOO', 'BAR'
69
- end
70
-
71
- x.report('dry-initializer (with UNDEFINED)') do
72
- DryTestUndefined.new 'FOO', 'BAR'
73
- end
74
-
75
- x.report('concord') do
76
- ConcordTest.new 'FOO', 'BAR'
77
- end
78
-
79
- x.report('attr_extras') do
80
- AttrExtrasText.new 'FOO', 'BAR'
81
- end
82
-
83
- x.compare!
84
- end