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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -21
- data/LICENSE +1 -1
- data/README.md +15 -27
- data/dry-configurable.gemspec +27 -18
- data/lib/dry-configurable.rb +2 -0
- data/lib/dry/configurable.rb +21 -146
- data/lib/dry/configurable/class_methods.rb +103 -0
- data/lib/dry/configurable/compiler.rb +45 -0
- data/lib/dry/configurable/config.rb +78 -136
- data/lib/dry/configurable/constants.rb +12 -0
- data/lib/dry/configurable/dsl.rb +62 -0
- data/lib/dry/configurable/dsl/args.rb +58 -0
- data/lib/dry/configurable/{error.rb → errors.rb} +5 -1
- data/lib/dry/configurable/instance_methods.rb +46 -0
- data/lib/dry/configurable/methods.rb +32 -0
- data/lib/dry/configurable/setting.rb +91 -18
- data/lib/dry/configurable/settings.rb +42 -87
- data/lib/dry/configurable/test_interface.rb +3 -5
- data/lib/dry/configurable/version.rb +3 -1
- metadata +30 -25
- data/.codeclimate.yml +0 -12
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
- data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -34
- data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
- data/.github/workflows/ci.yml +0 -70
- data/.github/workflows/docsite.yml +0 -34
- data/.github/workflows/sync_configs.yml +0 -30
- data/.gitignore +0 -9
- data/.rspec +0 -4
- data/.rubocop.yml +0 -89
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -20
- data/Rakefile +0 -12
- data/docsite/source/index.html.md +0 -55
- data/docsite/source/testing.html.md +0 -27
- data/lib/dry/configurable/settings/argument_parser.rb +0 -50
- 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
|
data/rakelib/rubocop.rake
DELETED
@@ -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
|