dry-configurable 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) 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 +34 -0
  5. data/.github/ISSUE_TEMPLATE/---feature-request.md +18 -0
  6. data/.github/workflows/ci.yml +70 -0
  7. data/.github/workflows/docsite.yml +34 -0
  8. data/.github/workflows/sync_configs.yml +30 -0
  9. data/.gitignore +1 -1
  10. data/.rspec +3 -1
  11. data/.rubocop.yml +89 -0
  12. data/CHANGELOG.md +87 -6
  13. data/CODE_OF_CONDUCT.md +13 -0
  14. data/CONTRIBUTING.md +29 -0
  15. data/Gemfile +4 -0
  16. data/LICENSE +1 -1
  17. data/README.md +20 -32
  18. data/docsite/source/index.html.md +55 -0
  19. data/docsite/source/testing.html.md +27 -0
  20. data/dry-configurable.gemspec +10 -4
  21. data/lib/dry/configurable.rb +124 -118
  22. data/lib/dry/configurable/config.rb +136 -43
  23. data/lib/dry/configurable/error.rb +0 -2
  24. data/lib/dry/configurable/setting.rb +46 -0
  25. data/lib/dry/configurable/settings.rb +117 -0
  26. data/lib/dry/configurable/settings/argument_parser.rb +50 -0
  27. data/lib/dry/configurable/test_interface.rb +5 -1
  28. data/lib/dry/configurable/version.rb +1 -1
  29. metadata +56 -38
  30. data/.ruby-version +0 -1
  31. data/.travis.yml +0 -34
  32. data/lib/dry/configurable/argument_parser.rb +0 -91
  33. data/lib/dry/configurable/config/value.rb +0 -27
  34. data/lib/dry/configurable/nested_config.rb +0 -33
  35. data/spec/integration/configurable_spec.rb +0 -25
  36. data/spec/spec_helper.rb +0 -92
  37. data/spec/support/shared_examples/configurable.rb +0 -391
  38. data/spec/unit/dry/configurable/argument_parser_spec.rb +0 -114
  39. data/spec/unit/dry/configurable/config/value_spec.rb +0 -55
  40. data/spec/unit/dry/configurable/config_spec.rb +0 -186
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  module Configurable
3
3
  # @api public
4
- VERSION = '0.7.0'.freeze
4
+ VERSION = '0.9.0'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,69 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-configurable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dry-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.4.7
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.4'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.4.7
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: bundler
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
- - - '>='
51
+ - - ">="
32
52
  - !ruby/object:Gem::Version
33
53
  version: '0'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
- - - '>='
58
+ - - ">="
39
59
  - !ruby/object:Gem::Version
40
60
  version: '0'
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: rake
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
45
- - - '>='
65
+ - - ">="
46
66
  - !ruby/object:Gem::Version
47
67
  version: '0'
48
68
  type: :development
49
69
  prerelease: false
50
70
  version_requirements: !ruby/object:Gem::Requirement
51
71
  requirements:
52
- - - '>='
72
+ - - ">="
53
73
  - !ruby/object:Gem::Version
54
74
  version: '0'
55
75
  - !ruby/object:Gem::Dependency
56
76
  name: rspec
57
77
  requirement: !ruby/object:Gem::Requirement
58
78
  requirements:
59
- - - '>='
79
+ - - ">="
60
80
  - !ruby/object:Gem::Version
61
81
  version: '0'
62
82
  type: :development
63
83
  prerelease: false
64
84
  version_requirements: !ruby/object:Gem::Requirement
65
85
  requirements:
66
- - - '>='
86
+ - - ">="
67
87
  - !ruby/object:Gem::Version
68
88
  version: '0'
69
89
  description:
@@ -73,61 +93,59 @@ executables: []
73
93
  extensions: []
74
94
  extra_rdoc_files: []
75
95
  files:
76
- - .codeclimate.yml
77
- - .gitignore
78
- - .rspec
79
- - .ruby-version
80
- - .travis.yml
96
+ - ".codeclimate.yml"
97
+ - ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
98
+ - ".github/ISSUE_TEMPLATE/---bug-report.md"
99
+ - ".github/ISSUE_TEMPLATE/---feature-request.md"
100
+ - ".github/workflows/ci.yml"
101
+ - ".github/workflows/docsite.yml"
102
+ - ".github/workflows/sync_configs.yml"
103
+ - ".gitignore"
104
+ - ".rspec"
105
+ - ".rubocop.yml"
81
106
  - CHANGELOG.md
107
+ - CODE_OF_CONDUCT.md
108
+ - CONTRIBUTING.md
82
109
  - Gemfile
83
110
  - LICENSE
84
111
  - README.md
85
112
  - Rakefile
113
+ - docsite/source/index.html.md
114
+ - docsite/source/testing.html.md
86
115
  - dry-configurable.gemspec
87
116
  - lib/dry-configurable.rb
88
117
  - lib/dry/configurable.rb
89
- - lib/dry/configurable/argument_parser.rb
90
118
  - lib/dry/configurable/config.rb
91
- - lib/dry/configurable/config/value.rb
92
119
  - lib/dry/configurable/error.rb
93
- - lib/dry/configurable/nested_config.rb
120
+ - lib/dry/configurable/setting.rb
121
+ - lib/dry/configurable/settings.rb
122
+ - lib/dry/configurable/settings/argument_parser.rb
94
123
  - lib/dry/configurable/test_interface.rb
95
124
  - lib/dry/configurable/version.rb
96
125
  - rakelib/rubocop.rake
97
- - spec/integration/configurable_spec.rb
98
- - spec/spec_helper.rb
99
- - spec/support/shared_examples/configurable.rb
100
- - spec/unit/dry/configurable/argument_parser_spec.rb
101
- - spec/unit/dry/configurable/config/value_spec.rb
102
- - spec/unit/dry/configurable/config_spec.rb
103
- homepage: https://github.com/dryrb/dry-configurable
126
+ homepage: https://github.com/dry-rb/dry-configurable
104
127
  licenses:
105
128
  - MIT
106
- metadata: {}
129
+ metadata:
130
+ source_code_uri: https://github.com/dry-rb/dry-configurable
131
+ changelog_uri: https://github.com/dry-rb/dry-configurable/blob/master/CHANGELOG.md
107
132
  post_install_message:
108
133
  rdoc_options: []
109
134
  require_paths:
110
135
  - lib
111
136
  required_ruby_version: !ruby/object:Gem::Requirement
112
137
  requirements:
113
- - - '>='
138
+ - - ">="
114
139
  - !ruby/object:Gem::Version
115
- version: '0'
140
+ version: 2.4.0
116
141
  required_rubygems_version: !ruby/object:Gem::Requirement
117
142
  requirements:
118
- - - '>='
143
+ - - ">="
119
144
  - !ruby/object:Gem::Version
120
145
  version: '0'
121
146
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.4.8
147
+ rubygems_version: 3.0.6
124
148
  signing_key:
125
149
  specification_version: 4
126
150
  summary: A mixin to add configuration functionality to your classes
127
- test_files:
128
- - spec/integration/configurable_spec.rb
129
- - spec/spec_helper.rb
130
- - spec/support/shared_examples/configurable.rb
131
- - spec/unit/dry/configurable/argument_parser_spec.rb
132
- - spec/unit/dry/configurable/config/value_spec.rb
133
- - spec/unit/dry/configurable/config_spec.rb
151
+ test_files: []
@@ -1 +0,0 @@
1
- 2.0.0-p247
@@ -1,34 +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.0
12
- - 2.1
13
- - 2.2
14
- - 2.3.1
15
- - rbx-3
16
- - jruby-9.1.5.0
17
- - ruby-head
18
- - jruby-head
19
- env:
20
- global:
21
- - JRUBY_OPTS='--dev -J-Xmx1024M'
22
- - COVERAGE='true'
23
- matrix:
24
- allow_failures:
25
- - rvm: ruby-head
26
- - rvm: jruby-head
27
- notifications:
28
- email: false
29
- webhooks:
30
- urls:
31
- - https://webhooks.gitter.im/e/19098b4253a72c9796db
32
- on_success: change # options: [always|never|change] default: always
33
- on_failure: always # options: [always|never|change] default: always
34
- on_start: false # default: false
@@ -1,91 +0,0 @@
1
- module Dry
2
- # Argument parser
3
- #
4
- # Passing and array or arguments, it will decide wich 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.
10
- #
11
- # @example
12
- # p = Dry::Configurable::ArgumentParser.new(['db:sqlite', { reader: true })
13
- #
14
- # p.value # => 'db:sqlite'
15
- # p.options # => { reader: true }
16
- #
17
- # Dry::Configurable::ArgumentParser.call(['db:sqlite', { reader: true })
18
- # # => [ 'db:sqlite', { reader: true } ]
19
- module Configurable
20
- # @private
21
- class ArgumentParser
22
- VALID_OPTIONS = %i(reader).freeze
23
-
24
- def self.call(data)
25
- parsed = new(data)
26
- [parsed.value, parsed.options]
27
- end
28
-
29
- def initialize(data)
30
- @data = data
31
- end
32
-
33
- def value
34
- parse_args[:value]
35
- end
36
-
37
- def options
38
- parse_args[:options]
39
- end
40
-
41
- private
42
-
43
- attr_reader :data
44
-
45
- # @private
46
- def default_args
47
- { value: nil, options: {} }
48
- end
49
-
50
- # @private
51
- def parse_args
52
- return default_args if data.empty?
53
- if data.size > 1
54
- { value: data.first, options: check_options(data.last) }
55
- else
56
- default_args.merge(check_for_value_or_options(data.first))
57
- end
58
- end
59
-
60
- # @private
61
- def check_options(opts)
62
- return {} if opts.empty?
63
- opts.select { |k, _| VALID_OPTIONS.include?(k) }
64
- end
65
-
66
- # @private
67
- def check_for_value_or_options(args)
68
- case args
69
- when Hash
70
- parse_hash(args)
71
- else
72
- { value: args }
73
- end
74
- end
75
-
76
- # @private
77
- def parse_hash(args)
78
- if hash_include_options_key(args)
79
- { options: check_options(args) }
80
- else
81
- { value: args }
82
- end
83
- end
84
-
85
- # @private
86
- def hash_include_options_key(hash)
87
- hash.any? { |k, _| VALID_OPTIONS.include?(k) }
88
- end
89
- end
90
- end
91
- end
@@ -1,27 +0,0 @@
1
- module Dry
2
- module Configurable
3
- class Config
4
- # @private
5
- class Value
6
- # @private
7
- NONE = ::Object.new.freeze
8
-
9
- attr_reader :name, :processor
10
-
11
- def initialize(name, value, processor)
12
- @name = name.to_sym
13
- @value = value
14
- @processor = processor
15
- end
16
-
17
- def value
18
- none? ? nil : @value
19
- end
20
-
21
- def none?
22
- @value.equal?(::Dry::Configurable::Config::Value::NONE)
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,33 +0,0 @@
1
- module Dry
2
- module Configurable
3
- # @private
4
- class NestedConfig
5
- def initialize(&block)
6
- klass = ::Class.new { extend ::Dry::Configurable }
7
- klass.instance_eval(&block)
8
- @klass = klass
9
- end
10
-
11
- # @private no, really...
12
- def create_config
13
- if @klass.instance_variables.include?(:@_config)
14
- @klass.__send__(:create_config)
15
- end
16
- end
17
-
18
- private
19
-
20
- def config
21
- @klass.config
22
- end
23
-
24
- def method_missing(method, *args, &block)
25
- config.respond_to?(method) ? config.public_send(method, *args, &block) : super
26
- end
27
-
28
- def respond_to_missing?(method, _include_private = false)
29
- config.respond_to?(method) || super
30
- end
31
- end
32
- end
33
- end
@@ -1,25 +0,0 @@
1
- RSpec.describe Dry::Configurable do
2
- context 'when extended' do
3
- let(:klass) do
4
- Class.new do
5
- extend Dry::Configurable
6
- end
7
- end
8
-
9
- it_behaves_like 'a configurable class'
10
- end
11
-
12
- context 'when extended then inherited' do
13
- let(:base_klass) do
14
- Class.new do
15
- extend Dry::Configurable
16
- end
17
- end
18
-
19
- let(:klass) do
20
- Class.new(base_klass)
21
- end
22
-
23
- it_behaves_like 'a configurable class'
24
- end
25
- end
@@ -1,92 +0,0 @@
1
- if ENV['COVERAGE'] == 'true' && RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.3.1'
2
- require 'simplecov'
3
-
4
- SimpleCov.start do
5
- add_filter '/spec/'
6
- end
7
- end
8
-
9
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
- RSpec.configure do |config|
11
- config.expect_with :rspec do |expectations|
12
- # This option will default to `true` in RSpec 4. It makes the `description`
13
- # and `failure_message` of custom matchers include text for helper methods
14
- # defined using `chain`, e.g.:
15
- # be_bigger_than(2).and_smaller_than(4).description
16
- # # => "be bigger than 2 and smaller than 4"
17
- # ...rather than:
18
- # # => "be bigger than 2"
19
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
20
- end
21
-
22
- config.mock_with :rspec do |mocks|
23
- # Prevents you from mocking or stubbing a method that does not exist on
24
- # a real object. This is generally recommended, and will default to
25
- # `true` in RSpec 4.
26
- mocks.verify_partial_doubles = true
27
- end
28
-
29
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
30
- # have no way to turn it off -- the option exists only for backwards
31
- # compatibility in RSpec 3). It causes shared context metadata to be
32
- # inherited by the metadata hash of host groups and examples, rather than
33
- # triggering implicit auto-inclusion in groups with matching metadata.
34
- config.shared_context_metadata_behavior = :apply_to_host_groups
35
-
36
- # This allows you to limit a spec run to individual examples or groups
37
- # you care about by tagging them with `:focus` metadata. When nothing
38
- # is tagged with `:focus`, all examples get run. RSpec also provides
39
- # aliases for `it`, `describe`, and `context` that include `:focus`
40
- # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
41
- config.filter_run_when_matching :focus
42
-
43
- # Allows RSpec to persist some state between runs in order to support
44
- # the `--only-failures` and `--next-failure` CLI options. We recommend
45
- # you configure your source control system to ignore this file.
46
- config.example_status_persistence_file_path = 'spec/examples.txt'
47
-
48
- # Limits the available syntax to the non-monkey patched syntax that is
49
- # recommended. For more details, see:
50
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
51
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
52
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
53
- config.disable_monkey_patching!
54
-
55
- # This setting enables warnings. It's recommended, but in some cases may
56
- # be too noisy due to issues in dependencies.
57
- config.warnings = true
58
-
59
- # Many RSpec users commonly either run the entire suite or an individual
60
- # file, and it's useful to allow more verbose output when running an
61
- # individual spec file.
62
- if config.files_to_run.one?
63
- # Use the documentation formatter for detailed output,
64
- # unless a formatter has already been configured
65
- # (e.g. via a command-line flag).
66
- config.default_formatter = 'doc'
67
- end
68
-
69
- # Print the n slowest examples and example groups at the
70
- # end of the spec run, to help surface which specs are running
71
- # particularly slow.
72
- config.profile_examples = 3
73
-
74
- # Run specs in random order to surface order dependencies. If you find an
75
- # order dependency and want to debug it, you can fix the order by providing
76
- # the seed, which is printed after each run.
77
- # --seed 1234
78
- config.order = :random
79
-
80
- # Seed global randomization in this process using the `--seed` CLI option.
81
- # Setting this allows you to use `--seed` to deterministically reproduce
82
- # test failures related to randomization by passing the same `--seed` value
83
- # as the one that triggered the failure.
84
- Kernel.srand config.seed
85
- end
86
-
87
- require 'dry/configurable'
88
- require 'dry/configurable/test_interface'
89
-
90
- Dir[Pathname(__FILE__).dirname.join('support/**/*.rb').to_s].each do |file|
91
- require file
92
- end