dry-configurable 0.9.0 → 0.11.0

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -21
  3. data/LICENSE +1 -1
  4. data/README.md +15 -27
  5. data/dry-configurable.gemspec +27 -18
  6. data/lib/dry-configurable.rb +2 -0
  7. data/lib/dry/configurable.rb +21 -146
  8. data/lib/dry/configurable/class_methods.rb +103 -0
  9. data/lib/dry/configurable/compiler.rb +45 -0
  10. data/lib/dry/configurable/config.rb +78 -136
  11. data/lib/dry/configurable/constants.rb +12 -0
  12. data/lib/dry/configurable/dsl.rb +62 -0
  13. data/lib/dry/configurable/dsl/args.rb +58 -0
  14. data/lib/dry/configurable/{error.rb → errors.rb} +5 -1
  15. data/lib/dry/configurable/instance_methods.rb +46 -0
  16. data/lib/dry/configurable/methods.rb +32 -0
  17. data/lib/dry/configurable/setting.rb +91 -18
  18. data/lib/dry/configurable/settings.rb +42 -87
  19. data/lib/dry/configurable/test_interface.rb +3 -5
  20. data/lib/dry/configurable/version.rb +3 -1
  21. metadata +30 -25
  22. data/.codeclimate.yml +0 -12
  23. data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
  24. data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -34
  25. data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
  26. data/.github/workflows/ci.yml +0 -70
  27. data/.github/workflows/docsite.yml +0 -34
  28. data/.github/workflows/sync_configs.yml +0 -30
  29. data/.gitignore +0 -9
  30. data/.rspec +0 -4
  31. data/.rubocop.yml +0 -89
  32. data/CODE_OF_CONDUCT.md +0 -13
  33. data/CONTRIBUTING.md +0 -29
  34. data/Gemfile +0 -20
  35. data/Rakefile +0 -12
  36. data/docsite/source/index.html.md +0 -55
  37. data/docsite/source/testing.html.md +0 -27
  38. data/lib/dry/configurable/settings/argument_parser.rb +0 -50
  39. data/rakelib/rubocop.rake +0 -18
@@ -1,27 +0,0 @@
1
- ---
2
- title: Testing
3
- layout: gem-single
4
- name: dry-configurable
5
- ---
6
-
7
- ### How to reset the config to its original state on testing environment
8
-
9
- update `spec_helper.rb` :
10
-
11
- ```ruby
12
- require "dry/configurable/test_interface"
13
-
14
- # this is your module/class that extended by Dry::Configurable
15
- module AwesomeModule
16
- enable_test_interface
17
- end
18
- ```
19
-
20
- and on spec file (`xxx_spec.rb`) :
21
-
22
- ```ruby
23
- before(:all) { AwesomeModule.reset_config }
24
- # or
25
- before(:each) { AwesomeModule.reset_config }
26
-
27
- ```
@@ -1,50 +0,0 @@
1
- module Dry
2
- # Argument parser
3
- #
4
- # Passing and array or arguments, it will decide which one are arguments
5
- # and which one are options.
6
- #
7
- # We have a limitation if setting the value without options, as a hash
8
- # having the same key as one of the valid options, will parse the value
9
- # as options. In this case, all unknown options will be reject with an exception.
10
- #
11
- # @example
12
- # p = Dry::Configurable::ArgumentParser.new.('db:sqlite', reader: true)
13
- #
14
- # p[0] # => 'db:sqlite'
15
- # p[1] # => ArgumentParser::DEFAULT_PROCESSOR
16
- # p[2] # => { reader: true }
17
- module Configurable
18
- class Settings
19
- # @private
20
- class ArgumentParser
21
- DEFAULT_PROCESSOR = ->(v) { v }
22
-
23
- # @private
24
- def call(val, opts, block)
25
- if block && block.parameters.empty?
26
- raise ArgumentError unless Undefined.equal?(opts)
27
-
28
- processor = DEFAULT_PROCESSOR
29
-
30
- value, options = Settings.capture(&block), val
31
- else
32
- processor = block || DEFAULT_PROCESSOR
33
-
34
- if Undefined.equal?(opts) && val.is_a?(Hash) && val.key?(:reader)
35
- value, options = Undefined, val
36
- else
37
- value, options = val, opts
38
- end
39
- end
40
-
41
- [value, processor, options(**Undefined.default(options, EMPTY_HASH))]
42
- end
43
-
44
- def options(reader: false)
45
- { reader: reader }
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,18 +0,0 @@
1
- begin
2
- require 'rubocop/rake_task'
3
-
4
- Rake::Task[:default].enhance [:rubocop]
5
-
6
- RuboCop::RakeTask.new do |task|
7
- task.options << '--display-cop-names'
8
- end
9
-
10
- namespace :rubocop do
11
- desc 'Generate a configuration file acting as a TODO list.'
12
- task :auto_gen_config do
13
- exec 'bundle exec rubocop --auto-gen-config'
14
- end
15
- end
16
-
17
- rescue LoadError
18
- end