dry-configurable 0.8.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 +82 -16
- data/LICENSE +1 -1
- data/README.md +17 -28
- data/dry-configurable.gemspec +29 -15
- data/lib/dry-configurable.rb +2 -0
- data/lib/dry/configurable.rb +23 -131
- data/lib/dry/configurable/class_methods.rb +103 -0
- data/lib/dry/configurable/compiler.rb +45 -0
- data/lib/dry/configurable/config.rb +81 -115
- 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 +95 -13
- data/lib/dry/configurable/settings.rb +43 -63
- data/lib/dry/configurable/test_interface.rb +3 -5
- data/lib/dry/configurable/version.rb +3 -1
- metadata +33 -17
- data/.codeclimate.yml +0 -23
- data/.gitignore +0 -8
- data/.rspec +0 -2
- data/.travis.yml +0 -27
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -17
- data/Rakefile +0 -12
- data/lib/dry/configurable/settings/argument_parser.rb +0 -50
- data/rakelib/rubocop.rake +0 -18
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: trusty
|
3
|
-
sudo: required
|
4
|
-
cache: bundler
|
5
|
-
bundler_args: --without console
|
6
|
-
script:
|
7
|
-
- bundle exec rake spec
|
8
|
-
after_success:
|
9
|
-
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
10
|
-
rvm:
|
11
|
-
- 2.3.8
|
12
|
-
- 2.4.5
|
13
|
-
- 2.5.3
|
14
|
-
- 2.6.0
|
15
|
-
- jruby-9.2.5.0
|
16
|
-
env:
|
17
|
-
global:
|
18
|
-
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
19
|
-
- COVERAGE='true'
|
20
|
-
notifications:
|
21
|
-
email: false
|
22
|
-
webhooks:
|
23
|
-
urls:
|
24
|
-
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
25
|
-
on_success: change # options: [always|never|change] default: always
|
26
|
-
on_failure: always # options: [always|never|change] default: always
|
27
|
-
on_start: false # default: false
|
data/CONTRIBUTING.md
DELETED
@@ -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 [discuss.dry-rb.org](https://discuss.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 [discuss.dry-rb.org](http://discuss.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 [discuss.dry-rb.org](https://discuss.dry-rb.org).
|
data/Gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
platforms :mri do
|
7
|
-
gem 'codeclimate-test-reporter', require: false
|
8
|
-
gem 'simplecov', require: false
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
group :tools do
|
13
|
-
gem 'guard'
|
14
|
-
gem 'guard-rspec'
|
15
|
-
gem 'listen', '3.0.6'
|
16
|
-
gem 'pry-byebug', platform: :mri
|
17
|
-
end
|
data/Rakefile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
require 'bundler/gem_tasks'
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
5
|
-
|
6
|
-
require 'rspec/core'
|
7
|
-
require 'rspec/core/rake_task'
|
8
|
-
|
9
|
-
task default: :spec
|
10
|
-
|
11
|
-
desc 'Run all specs in spec directory'
|
12
|
-
RSpec::Core::RakeTask.new(:spec)
|
@@ -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
|