dry-initializer 2.4.0 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) 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 +30 -0
  5. data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
  6. data/.github/workflows/custom_ci.yml +58 -0
  7. data/.github/workflows/docsite.yml +34 -0
  8. data/.github/workflows/sync_configs.yml +56 -0
  9. data/.gitignore +2 -0
  10. data/.rspec +1 -1
  11. data/.rubocop.yml +76 -25
  12. data/CHANGELOG.md +150 -14
  13. data/CODE_OF_CONDUCT.md +13 -0
  14. data/CONTRIBUTING.md +29 -0
  15. data/Gemfile +25 -18
  16. data/Gemfile.devtools +16 -0
  17. data/Guardfile +3 -3
  18. data/LICENSE +20 -0
  19. data/README.md +17 -79
  20. data/Rakefile +4 -4
  21. data/benchmarks/compare_several_defaults.rb +27 -27
  22. data/benchmarks/plain_options.rb +14 -14
  23. data/benchmarks/plain_params.rb +22 -22
  24. data/benchmarks/with_coercion.rb +14 -14
  25. data/benchmarks/with_defaults.rb +17 -17
  26. data/benchmarks/with_defaults_and_coercion.rb +14 -14
  27. data/bin/.gitkeep +0 -0
  28. data/docsite/source/attributes.html.md +106 -0
  29. data/docsite/source/container-version.html.md +39 -0
  30. data/docsite/source/index.html.md +43 -0
  31. data/docsite/source/inheritance.html.md +43 -0
  32. data/docsite/source/optionals-and-defaults.html.md +130 -0
  33. data/docsite/source/options-tolerance.html.md +27 -0
  34. data/docsite/source/params-and-options.html.md +74 -0
  35. data/docsite/source/rails-support.html.md +101 -0
  36. data/docsite/source/readers.html.md +43 -0
  37. data/docsite/source/skip-undefined.html.md +59 -0
  38. data/docsite/source/type-constraints.html.md +160 -0
  39. data/dry-initializer.gemspec +13 -13
  40. data/lib/dry-initializer.rb +1 -1
  41. data/lib/dry/initializer.rb +17 -16
  42. data/lib/dry/initializer/builders.rb +2 -2
  43. data/lib/dry/initializer/builders/attribute.rb +16 -11
  44. data/lib/dry/initializer/builders/initializer.rb +9 -13
  45. data/lib/dry/initializer/builders/reader.rb +4 -2
  46. data/lib/dry/initializer/builders/signature.rb +3 -3
  47. data/lib/dry/initializer/config.rb +25 -12
  48. data/lib/dry/initializer/definition.rb +20 -71
  49. data/lib/dry/initializer/dispatchers.rb +101 -33
  50. data/lib/dry/initializer/dispatchers/build_nested_type.rb +59 -0
  51. data/lib/dry/initializer/dispatchers/check_type.rb +43 -0
  52. data/lib/dry/initializer/dispatchers/prepare_default.rb +40 -0
  53. data/lib/dry/initializer/dispatchers/prepare_ivar.rb +12 -0
  54. data/lib/dry/initializer/dispatchers/prepare_optional.rb +13 -0
  55. data/lib/dry/initializer/dispatchers/prepare_reader.rb +30 -0
  56. data/lib/dry/initializer/dispatchers/prepare_source.rb +28 -0
  57. data/lib/dry/initializer/dispatchers/prepare_target.rb +44 -0
  58. data/lib/dry/initializer/dispatchers/unwrap_type.rb +22 -0
  59. data/lib/dry/initializer/dispatchers/wrap_type.rb +28 -0
  60. data/lib/dry/initializer/mixin.rb +4 -4
  61. data/lib/dry/initializer/mixin/root.rb +1 -0
  62. data/lib/dry/initializer/struct.rb +39 -0
  63. data/lib/dry/initializer/undefined.rb +2 -0
  64. data/lib/dry/initializer/version.rb +5 -0
  65. data/lib/tasks/benchmark.rake +13 -13
  66. data/lib/tasks/profile.rake +16 -16
  67. data/project.yml +2 -0
  68. data/spec/attributes_spec.rb +7 -7
  69. data/spec/coercion_of_nil_spec.rb +25 -0
  70. data/spec/custom_dispatchers_spec.rb +6 -6
  71. data/spec/custom_initializer_spec.rb +2 -2
  72. data/spec/default_values_spec.rb +9 -9
  73. data/spec/definition_spec.rb +16 -12
  74. data/spec/invalid_default_spec.rb +2 -2
  75. data/spec/list_type_spec.rb +32 -0
  76. data/spec/missed_default_spec.rb +2 -2
  77. data/spec/nested_type_spec.rb +48 -0
  78. data/spec/optional_spec.rb +16 -16
  79. data/spec/options_tolerance_spec.rb +2 -2
  80. data/spec/public_attributes_utility_spec.rb +5 -5
  81. data/spec/reader_spec.rb +13 -13
  82. data/spec/repetitive_definitions_spec.rb +9 -9
  83. data/spec/several_assignments_spec.rb +9 -9
  84. data/spec/spec_helper.rb +6 -3
  85. data/spec/subclassing_spec.rb +5 -5
  86. data/spec/support/coverage.rb +7 -0
  87. data/spec/support/warnings.rb +7 -0
  88. data/spec/type_argument_spec.rb +15 -15
  89. data/spec/type_constraint_spec.rb +46 -28
  90. data/spec/value_coercion_via_dry_types_spec.rb +8 -8
  91. metadata +51 -34
  92. data/.travis.yml +0 -24
@@ -0,0 +1,13 @@
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)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,29 @@
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 CHANGED
@@ -1,29 +1,36 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
+
3
+ eval_gemfile 'Gemfile.devtools'
2
4
 
3
- # Specify your gem"s dependencies in dry-initializer.gemspec
4
5
  gemspec
5
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
+
6
13
  group :benchmarks do
7
- if RUBY_VERSION < "2.4"
8
- gem "activesupport", "< 5"
14
+ if RUBY_VERSION < '2.4'
15
+ gem 'activesupport', '< 5'
9
16
  else
10
- gem "activesupport"
17
+ gem 'activesupport'
11
18
  end
12
19
 
13
- gem "active_attr"
14
- gem "anima"
15
- gem "attr_extras"
16
- gem "benchmark-ips", "~> 2.5"
17
- gem "concord"
18
- gem "fast_attributes"
19
- gem "kwattr"
20
- gem "ruby-prof"
21
- gem "value_struct"
22
- gem "values"
23
- gem "virtus"
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'
24
31
  end
25
32
 
26
33
  group :development, :test do
27
- gem "pry", platform: :mri
28
- gem "pry-byebug", platform: :mri
34
+ gem 'pry', platform: :mri
35
+ gem 'pry-byebug', platform: :mri
29
36
  end
data/Gemfile.devtools ADDED
@@ -0,0 +1,16 @@
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 CHANGED
@@ -1,5 +1,5 @@
1
- guard :rspec, cmd: "bundle exec rspec" do
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^spec/(spec_helper|support)}) { "spec" }
4
- watch(%r{^lib/.+}) { "spec" }
3
+ watch(%r{^spec/(spec_helper|support)}) { 'spec' }
4
+ watch(%r{^lib/.+}) { 'spec' }
5
5
  end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2020 dry-rb team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,91 +1,29 @@
1
- # dry-initializer [![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dry-rb/chat)
2
-
3
- [![Gem Version](https://badge.fury.io/rb/dry-initializer.svg)][gem]
4
- [![Build Status](https://travis-ci.org/dry-rb/dry-initializer.svg?branch=master)][travis]
5
- [![Dependency Status](https://gemnasium.com/dry-rb/dry-initializer.svg)][gemnasium]
6
- [![Code Climate](https://codeclimate.com/github/dry-rb/dry-initializer/badges/gpa.svg)][codeclimate]
7
- [![Test Coverage](https://codeclimate.com/github/dry-rb/dry-initializer/badges/coverage.svg)][coveralls]
8
- [![Inline docs](http://inch-ci.org/github/dry-rb/dry-initializer.svg?branch=master)][inchpages]
9
-
10
1
  [gem]: https://rubygems.org/gems/dry-initializer
11
- [travis]: https://travis-ci.org/dry-rb/dry-initializer
12
- [gemnasium]: https://gemnasium.com/dry-rb/dry-initializer
13
- [codeclimate]: https://codeclimate.com/github/dry-rb/dry-initializer
14
- [coveralls]: https://coveralls.io/r/dry-rb/dry-initializer
2
+ [actions]: https://github.com/dry-rb/dry-initializer/actions
3
+ [codacy]: https://www.codacy.com/gh/dry-rb/dry-initializer
4
+ [chat]: https://dry-rb.zulipchat.com
15
5
  [inchpages]: http://inch-ci.org/github/dry-rb/dry-initializer
16
- [docs]: http://dry-rb.org/gems/dry-initializer/
17
- [benchmarks]: https://github.com/dry-rb/dry-initializer/wiki
18
- [license]: http://opensource.org/licenses/MIT
19
-
20
- DSL for building class initializer with params and options.
21
-
22
- ## Installation
23
-
24
- Add this line to your application's Gemfile:
25
-
26
- ```ruby
27
- gem 'dry-initializer'
28
- ```
29
-
30
- And then execute:
31
-
32
- ```shell
33
- $ bundle
34
- ```
35
-
36
- Or install it yourself as:
37
6
 
38
- ```shell
39
- $ gem install dry-initializer
40
- ```
7
+ # dry-initializer [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
41
8
 
42
- ## Synopsis
43
-
44
- ```ruby
45
- require 'dry-initializer'
46
- require 'dry-types'
47
-
48
- class User
49
- extend Dry::Initializer
50
-
51
- # Params of the initializer along with corresponding readers
52
- param :name, proc(&:to_s)
53
- param :role, default: -> { 'customer' }
54
- # Options of the initializer along with corresponding readers
55
- option :admin, default: -> { false }
56
- option :vip, optional: true
57
- end
58
-
59
- # Defines the initializer with params and options
60
- user = User.new 'Vladimir', 'admin', admin: true
61
-
62
- # Defines readers for single attributes
63
- user.name # => 'Vladimir'
64
- user.role # => 'admin'
65
- user.admin # => true
66
- user.vip # => Dry::Initializer::UNDEFINED
67
- ```
68
-
69
- See full documentation on the [Dry project official site][docs]
70
-
71
- ## Benchmarks
9
+ [![Gem Version](https://badge.fury.io/rb/dry-initializer.svg)][gem]
10
+ [![CI Status](https://github.com/dry-rb/dry-initializer/workflows/ci/badge.svg)][actions]
11
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/03c8923afd734e9fb0f4bfe9cc893edb)][codacy]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/03c8923afd734e9fb0f4bfe9cc893edb)][codacy]
13
+ [![Inline docs](http://inch-ci.org/github/dry-rb/dry-initializer.svg?branch=master)][inchpages]
72
14
 
73
- The `dry-initializer` is pretty fast for rubies 2.2+ [comparing to other libraries][benchmarks].
15
+ ## Links
74
16
 
75
- ## Compatibility
17
+ * [User documentation](http://dry-rb.org/gems/dry-initializer)
18
+ * [API documentation](http://rubydoc.info/gems/dry-initializer)
76
19
 
77
- Tested under rubies [compatible to MRI 2.2+](.travis.yml).
20
+ ## Supported Ruby versions
78
21
 
79
- ## Contributing
22
+ This library officially supports the following Ruby versions:
80
23
 
81
- * [Fork the project](https://github.com/dry-rb/dry-initializer)
82
- * Create your feature branch (`git checkout -b my-new-feature`)
83
- * Add tests for it
84
- * Commit your changes (`git commit -am '[UPDATE] Add some feature'`)
85
- * Push to the branch (`git push origin my-new-feature`)
86
- * Create a new Pull Request
24
+ * MRI >= `2.4`
25
+ * jruby >= `9.2`
87
26
 
88
27
  ## License
89
28
 
90
- The gem is available as open source under the terms of the [MIT License][license].
91
-
29
+ See `LICENSE` file.
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- require "bundler/setup"
1
+ require 'bundler/setup'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require "rspec/core/rake_task"
4
+ require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new :default
6
6
 
7
- load "lib/tasks/benchmark.rake"
8
- load "lib/tasks/profile.rake"
7
+ load 'lib/tasks/benchmark.rake'
8
+ load 'lib/tasks/profile.rake'
@@ -1,6 +1,6 @@
1
1
  Bundler.require(:benchmarks)
2
2
 
3
- require "dry-initializer"
3
+ require 'dry-initializer'
4
4
  class WithoutDefaults
5
5
  extend Dry::Initializer
6
6
 
@@ -14,67 +14,67 @@ class WithOneDefault
14
14
 
15
15
  param :foo
16
16
  param :bar
17
- param :baz, default: proc { "BAZ" }
17
+ param :baz, default: proc { 'BAZ' }
18
18
  end
19
19
 
20
20
  class WithTwoDefaults
21
21
  extend Dry::Initializer
22
22
 
23
23
  param :foo
24
- param :bar, default: proc { "BAR" }
25
- param :baz, default: proc { "BAZ" }
24
+ param :bar, default: proc { 'BAR' }
25
+ param :baz, default: proc { 'BAZ' }
26
26
  end
27
27
 
28
28
  class WithThreeDefaults
29
29
  extend Dry::Initializer
30
30
 
31
- param :foo, default: proc { "FOO" }
32
- param :bar, default: proc { "BAR" }
33
- param :baz, default: proc { "BAZ" }
31
+ param :foo, default: proc { 'FOO' }
32
+ param :bar, default: proc { 'BAR' }
33
+ param :baz, default: proc { 'BAZ' }
34
34
  end
35
35
 
36
- puts "Benchmark for various options"
36
+ puts 'Benchmark for various options'
37
37
 
38
38
  Benchmark.ips do |x|
39
39
  x.config time: 15, warmup: 10
40
40
 
41
- x.report("without defaults") do
42
- WithoutDefaults.new "FOO", "BAR", "BAZ"
41
+ x.report('without defaults') do
42
+ WithoutDefaults.new 'FOO', 'BAR', 'BAZ'
43
43
  end
44
44
 
45
- x.report("with 0 of 1 default used") do
46
- WithOneDefault.new "FOO", "BAR", "BAZ"
45
+ x.report('with 0 of 1 default used') do
46
+ WithOneDefault.new 'FOO', 'BAR', 'BAZ'
47
47
  end
48
48
 
49
- x.report("with 1 of 1 default used") do
50
- WithOneDefault.new "FOO", "BAR"
49
+ x.report('with 1 of 1 default used') do
50
+ WithOneDefault.new 'FOO', 'BAR'
51
51
  end
52
52
 
53
- x.report("with 0 of 2 defaults used") do
54
- WithTwoDefaults.new "FOO", "BAR", "BAZ"
53
+ x.report('with 0 of 2 defaults used') do
54
+ WithTwoDefaults.new 'FOO', 'BAR', 'BAZ'
55
55
  end
56
56
 
57
- x.report("with 1 of 2 defaults used") do
58
- WithTwoDefaults.new "FOO", "BAR"
57
+ x.report('with 1 of 2 defaults used') do
58
+ WithTwoDefaults.new 'FOO', 'BAR'
59
59
  end
60
60
 
61
- x.report("with 2 of 2 defaults used") do
62
- WithTwoDefaults.new "FOO"
61
+ x.report('with 2 of 2 defaults used') do
62
+ WithTwoDefaults.new 'FOO'
63
63
  end
64
64
 
65
- x.report("with 0 of 3 defaults used") do
66
- WithThreeDefaults.new "FOO", "BAR", "BAZ"
65
+ x.report('with 0 of 3 defaults used') do
66
+ WithThreeDefaults.new 'FOO', 'BAR', 'BAZ'
67
67
  end
68
68
 
69
- x.report("with 1 of 3 defaults used") do
70
- WithThreeDefaults.new "FOO", "BAR"
69
+ x.report('with 1 of 3 defaults used') do
70
+ WithThreeDefaults.new 'FOO', 'BAR'
71
71
  end
72
72
 
73
- x.report("with 2 of 3 defaults used") do
74
- WithThreeDefaults.new "FOO"
73
+ x.report('with 2 of 3 defaults used') do
74
+ WithThreeDefaults.new 'FOO'
75
75
  end
76
76
 
77
- x.report("with 3 of 3 defaults used") do
77
+ x.report('with 3 of 3 defaults used') do
78
78
  WithThreeDefaults.new
79
79
  end
80
80
 
@@ -1,6 +1,6 @@
1
1
  Bundler.require(:benchmarks)
2
2
 
3
- require "dry-initializer"
3
+ require 'dry-initializer'
4
4
  class DryTest
5
5
  extend Dry::Initializer[undefined: false]
6
6
 
@@ -24,39 +24,39 @@ class PlainRubyTest
24
24
  end
25
25
  end
26
26
 
27
- require "anima"
27
+ require 'anima'
28
28
  class AnimaTest
29
29
  include Anima.new(:foo, :bar)
30
30
  end
31
31
 
32
- require "kwattr"
32
+ require 'kwattr'
33
33
  class KwattrTest
34
34
  kwattr :foo, :bar
35
35
  end
36
36
 
37
- puts "Benchmark for instantiation with plain options"
37
+ puts 'Benchmark for instantiation with plain options'
38
38
 
39
39
  Benchmark.ips do |x|
40
40
  x.config time: 15, warmup: 10
41
41
 
42
- x.report("plain Ruby") do
43
- PlainRubyTest.new foo: "FOO", bar: "BAR"
42
+ x.report('plain Ruby') do
43
+ PlainRubyTest.new foo: 'FOO', bar: 'BAR'
44
44
  end
45
45
 
46
- x.report("dry-initializer") do
47
- DryTest.new foo: "FOO", bar: "BAR"
46
+ x.report('dry-initializer') do
47
+ DryTest.new foo: 'FOO', bar: 'BAR'
48
48
  end
49
49
 
50
- x.report("dry-initializer (with UNDEFINED)") do
51
- DryTestUndefined.new foo: "FOO", bar: "BAR"
50
+ x.report('dry-initializer (with UNDEFINED)') do
51
+ DryTestUndefined.new foo: 'FOO', bar: 'BAR'
52
52
  end
53
53
 
54
- x.report("anima") do
55
- AnimaTest.new foo: "FOO", bar: "BAR"
54
+ x.report('anima') do
55
+ AnimaTest.new foo: 'FOO', bar: 'BAR'
56
56
  end
57
57
 
58
- x.report("kwattr") do
59
- KwattrTest.new foo: "FOO", bar: "BAR"
58
+ x.report('kwattr') do
59
+ KwattrTest.new foo: 'FOO', bar: 'BAR'
60
60
  end
61
61
 
62
62
  x.compare!
@@ -1,6 +1,6 @@
1
1
  Bundler.require(:benchmarks)
2
2
 
3
- require "dry-initializer"
3
+ require 'dry-initializer'
4
4
  class DryTest
5
5
  extend Dry::Initializer[undefined: false]
6
6
 
@@ -26,58 +26,58 @@ end
26
26
 
27
27
  StructTest = Struct.new(:foo, :bar)
28
28
 
29
- require "concord"
29
+ require 'concord'
30
30
  class ConcordTest
31
31
  include Concord.new(:foo, :bar)
32
32
  end
33
33
 
34
- require "values"
34
+ require 'values'
35
35
  ValueTest = Value.new(:foo, :bar)
36
36
 
37
- require "value_struct"
37
+ require 'value_struct'
38
38
  ValueStructTest = ValueStruct.new(:foo, :bar)
39
39
 
40
- require "attr_extras"
40
+ require 'attr_extras'
41
41
  class AttrExtrasText
42
42
  attr_initialize :foo, :bar
43
43
  attr_reader :foo, :bar
44
44
  end
45
45
 
46
- puts "Benchmark for instantiation with plain params"
46
+ puts 'Benchmark for instantiation with plain params'
47
47
 
48
48
  Benchmark.ips do |x|
49
49
  x.config time: 15, warmup: 10
50
50
 
51
- x.report("plain Ruby") do
52
- PlainRubyTest.new "FOO", "BAR"
51
+ x.report('plain Ruby') do
52
+ PlainRubyTest.new 'FOO', 'BAR'
53
53
  end
54
54
 
55
- x.report("Core Struct") do
56
- StructTest.new "FOO", "BAR"
55
+ x.report('Core Struct') do
56
+ StructTest.new 'FOO', 'BAR'
57
57
  end
58
58
 
59
- x.report("values") do
60
- ValueTest.new "FOO", "BAR"
59
+ x.report('values') do
60
+ ValueTest.new 'FOO', 'BAR'
61
61
  end
62
62
 
63
- x.report("value_struct") do
64
- ValueStructTest.new "FOO", "BAR"
63
+ x.report('value_struct') do
64
+ ValueStructTest.new 'FOO', 'BAR'
65
65
  end
66
66
 
67
- x.report("dry-initializer") do
68
- DryTest.new "FOO", "BAR"
67
+ x.report('dry-initializer') do
68
+ DryTest.new 'FOO', 'BAR'
69
69
  end
70
70
 
71
- x.report("dry-initializer (with UNDEFINED)") do
72
- DryTestUndefined.new "FOO", "BAR"
71
+ x.report('dry-initializer (with UNDEFINED)') do
72
+ DryTestUndefined.new 'FOO', 'BAR'
73
73
  end
74
74
 
75
- x.report("concord") do
76
- ConcordTest.new "FOO", "BAR"
75
+ x.report('concord') do
76
+ ConcordTest.new 'FOO', 'BAR'
77
77
  end
78
78
 
79
- x.report("attr_extras") do
80
- AttrExtrasText.new "FOO", "BAR"
79
+ x.report('attr_extras') do
80
+ AttrExtrasText.new 'FOO', 'BAR'
81
81
  end
82
82
 
83
83
  x.compare!