dry-configurable 0.8.3 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2952b22a9581b91b77a416925a150088ea715be486638e293beae10d5b493a8
4
- data.tar.gz: 6cf8073234d53e391e25d03eb0b3548694ebbaa30742169895b8f1d519f258d7
3
+ metadata.gz: b4e11fe2beb3ca860f4ef98b8f3fc6ea85d9a6f6057b655e8bc75390ec5e467f
4
+ data.tar.gz: 56492140c1b08b72debe6e949ef1b267620aced64ddfb723b9f46ac547cc998a
5
5
  SHA512:
6
- metadata.gz: 441ba5b074dd577bd0e0d37b5a99e76dc1ab85068885832e791eba4cd7a61e5691683f96c93e930a29d59e838b294d82248074433c670466ad31f773e1994dab
7
- data.tar.gz: 02f13c05320aca5bb6900dd831966c3edc760fd66b9bfe40f94d079da0f3af30ecbdd07cdd024807d305296caf55f1b1613c285cdec86db97fb57659c42c11a0
6
+ metadata.gz: 7b5fee57d11e0e146e94c9b238b8f54244faab044168f62c1e34b29c597603dc99da65ddb65cf6572a5e8a2c695c706e00df4170ca5f9d3f6d8d16e6adb83fc4
7
+ data.tar.gz: 92706b85b212df1a27323e074dfcaf652a52c9e7ba08ef1c9905e1db33d99b8dc1ae88797ac56dde2110862cf76381d5d09db67f8d5e9a5afbc08f1f887aa375
data/CHANGELOG.md CHANGED
@@ -1,36 +1,105 @@
1
- ## 0.8.3 - 2019-05-29
1
+ ## 0.11.3 2020-02-22
2
2
 
3
- ## Fixed
4
3
 
5
- * `Configurable#dup` and `Configurable#clone` make a copy of instance-level config so that it doesn't get mutated/shared across instances (flash-gordon)
4
+ ### Fixed
5
+
6
+ - Retrieving settings by a string name works again (issue #82) (@waiting-for-dev)
7
+
8
+
9
+ [Compare v0.11.2...v0.11.3](https://github.com/dry-rb/dry-configurable/compare/v0.11.2...v0.11.3)
10
+
11
+ ## 0.11.2 2020-02-20
12
+
13
+
14
+ ### Fixed
15
+
16
+ - Warning about redefined `Setting#value` is gone (@solnic)
17
+
18
+
19
+ [Compare v0.11.1...v0.11.2](https://github.com/dry-rb/dry-configurable/compare/v0.11.1...v0.11.2)
20
+
21
+ ## 0.11.1 2020-02-18
22
+
23
+
24
+ ### Fixed
25
+
26
+ - You can use `:settings` as a config key again (issue #80) (@solnic)
27
+ - Setting value is lazy-evaluated now, which fixes some cases where a constructor could crash with a `nil` value (@solnic)
28
+
29
+
30
+ [Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-configurable/compare/v0.11.0...v0.11.1)
31
+
32
+ ## 0.11.0 2020-02-15
33
+
34
+ Complete rewrite of the library while keeping the public API intact. See #78 for a detailed overview.
35
+
36
+ ### Changed
37
+
38
+ - Accessing config in a parent class no longer prevents you from adding more settings in a child class (@solnic)
39
+ - (internal) New low-level Setting and Config API (@solnic)
40
+ - (internal) `config` objects use method_missing now (@solnic)
41
+
42
+ [Compare v0.10.0...v0.11.0](https://github.com/dry-rb/dry-configurable/compare/v0.10.0...v0.11.0)
43
+
44
+ ## 0.10.0 2020-01-31
45
+
46
+ YANKED because the change also broke inheritance for classes that used `configured` before other classes inherited from them.
47
+
48
+ ### Changed
49
+
50
+ - Inheriting settings no longer defines the config object. This change fixed a use case where parent class that already used its config would prevent a child class from adding new settings (@solnic)
51
+
52
+ [Compare v0.9.0...v0.10.0](https://github.com/dry-rb/dry-configurable/compare/v0.9.0...v0.10.0)
53
+
54
+ ## 0.9.0 2019-11-06
55
+
56
+
57
+ ### Fixed
58
+
59
+ - Support for reserved names in settings. Some Kernel methods (`public_send` and `class` specifically) are not available if you use access settings via method call. Same for methods of the `Config` class. You can still access them with `[]` and `[]=`. Ruby keywords are fully supported. Invalid names containing special symbols (including `!` and `?`) are rejected. Note that these changes don't affect the `reader` option, if you define a setting named `:class` and pass `reader: true` ... well ... (flash-gordon)
60
+ - Settings can be redefined in subclasses without a warning about overriding exsting methods (flash-gordon)
61
+ - Fix warnings about using keyword arguments in 2.7 (koic)
62
+
63
+
64
+ [Compare v0.8.3...v0.9.0](https://github.com/dry-rb/dry-configurable/compare/v0.8.3...v0.9.0)
65
+
66
+ ## 0.8.3 2019-05-29
67
+
68
+
69
+ ### Fixed
70
+
71
+ - `Configurable#dup` and `Configurable#clone` make a copy of instance-level config so that it doesn't get mutated/shared across instances (flash-gordon)
72
+
6
73
 
7
74
  [Compare v0.8.2...v0.8.3](https://github.com/dry-rb/dry-configurable/compare/v0.8.2...v0.8.3)
8
75
 
9
- ## 0.8.2 - 2019-02-25
76
+ ## 0.8.2 2019-02-25
77
+
78
+
79
+ ### Fixed
10
80
 
11
- ## Fixed
81
+ - Test interface support for modules ([Neznauy](https://github.com/Neznauy))
12
82
 
13
- * Test interface support for modules ([Neznauy](https://github.com/Neznauy))
14
83
 
15
84
  [Compare v0.8.1...v0.8.2](https://github.com/dry-rb/dry-configurable/compare/v0.8.1...v0.8.2)
16
85
 
17
- ## 0.8.1 - 2019-02-06
86
+ ## 0.8.1 2019-02-06
18
87
 
19
- ## Fixed
20
88
 
21
- * `.configure` doesn't require a block, this makes the behavior consistent with the previous versions ([flash-gordon](https://github.com/flash-gordon))
89
+ ### Fixed
90
+
91
+ - `.configure` doesn't require a block, this makes the behavior consistent with the previous versions ([flash-gordon](https://github.com/flash-gordon))
92
+
22
93
 
23
94
  [Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-configurable/compare/v0.8.0...v0.8.1)
24
95
 
25
- ## 0.8.0 - 2019-02-05
96
+ ## 0.8.0 2019-02-05
26
97
 
27
- ## Fixed
28
98
 
29
- * A number of bugs related to inheriting settings from parent class were fixed. Ideally, new behavior will be :100: predictable but if you observe any anomaly, please report ([flash-gordon](https://github.com/flash-gordon))
99
+ ### Added
30
100
 
31
- ## Added
101
+ - Support for instance-level configuration landed. For usage, `include` the module instead of extending ([flash-gordon](https://github.com/flash-gordon))
32
102
 
33
- * Support for instance-level configuration landed. For usage, `include` the module instead of extending ([flash-gordon](https://github.com/flash-gordon))
34
103
  ```ruby
35
104
  class App
36
105
  include Dry::Configurable
@@ -46,7 +115,8 @@
46
115
  development.config.database = 'jdbc:sqlite:memory'
47
116
  development.finalize!
48
117
  ```
49
- * Config values can be set from a hash with `.update`. Nested settings are supported ([flash-gordon](https://github.com/flash-gordon))
118
+ - Config values can be set from a hash with `.update`. Nested settings are supported ([flash-gordon](https://github.com/flash-gordon))
119
+
50
120
  ```ruby
51
121
  class App
52
122
  extend Dry::Configurable
@@ -60,22 +130,25 @@
60
130
  end
61
131
  ```
62
132
 
63
- ## Changed
133
+ ### Fixed
134
+
135
+ - A number of bugs related to inheriting settings from parent class were fixed. Ideally, new behavior will be :100: predictable but if you observe any anomaly, please report ([flash-gordon](https://github.com/flash-gordon))
136
+
137
+ ### Changed
64
138
 
65
- * [BREAKING] Minimal supported Ruby version is set to 2.3 ([flash-gordon](https://github.com/flash-gordon))
139
+ - [BREAKING] Minimal supported Ruby version is set to 2.3 ([flash-gordon](https://github.com/flash-gordon))
66
140
 
67
141
  [Compare v0.7.0...v0.8.0](https://github.com/dry-rb/dry-configurable/compare/v0.7.0...v0.8.0)
68
142
 
69
- ## 0.7.0 - 2017-04-25
143
+ ## 0.7.0 2017-04-25
70
144
 
71
- ## Added
72
145
 
73
- * Introduce `Configurable.finalize!` which freezes config and its dependencies ([qcam](https://github.com/qcam))
146
+ ### Added
74
147
 
75
- ## Fixed
148
+ - Introduce `Configurable.finalize!` which freezes config and its dependencies ([qcam](https://github.com/qcam))
76
149
 
77
- * Allow for boolean false as default setting value ([yuszuv](https://github.com/yuszuv))
78
- * Convert nested configs to nested hashes with `Config#to_h` ([saverio-kantox](https://github.com/saverio-kantox))
79
- * Disallow modification on frozen config ([qcam](https://github.com/qcam))
150
+ ### Fixed
80
151
 
81
- [Compare v0.6.2...v0.7.0](https://github.com/dry-rb/dry-configurable/compare/v0.6.2...v0.7.0)
152
+ - Allow for boolean false as default setting value ([yuszuv](https://github.com/yuszuv))
153
+ - Convert nested configs to nested hashes with `Config#to_h` ([saverio-kantox](https://github.com/saverio-kantox))
154
+ - Disallow modification on frozen config ([qcam](https://github.com/qcam))
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2017 dry-rb
3
+ Copyright (c) 2015-2020 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,40 +1,28 @@
1
- [gitter]: https://gitter.im/dry-rb/chat
2
1
  [gem]: https://rubygems.org/gems/dry-configurable
3
- [travis]: https://travis-ci.org/dry-rb/dry-configurable
4
- [inch]: http://inch-ci.org/github/dry-rb/dry-configurable
2
+ [actions]: https://github.com/dry-rb/dry-configurable/actions
3
+ [codacy]: https://www.codacy.com/gh/dry-rb/dry-configurable
5
4
  [chat]: https://dry-rb.zulipchat.com
5
+ [inchpages]: http://inch-ci.org/github/dry-rb/dry-configurable
6
6
 
7
7
  # dry-configurable [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
8
8
 
9
- [![Gem Version](https://img.shields.io/gem/v/dry-configurable.svg)][gem]
10
- [![Build Status](https://img.shields.io/travis/dry-rb/dry-configurable.svg)][travis]
11
- [![Maintainability](https://api.codeclimate.com/v1/badges/25311e81391498d6b7c8/maintainability)](https://codeclimate.com/github/dry-rb/dry-configurable/maintainability)
12
- [![Test Coverage](https://api.codeclimate.com/v1/badges/25311e81391498d6b7c8/test_coverage)](https://codeclimate.com/github/dry-rb/dry-configurable/test_coverage)
13
- [![API Documentation Coverage](http://inch-ci.org/github/dry-rb/dry-configurable.svg)][inch]
9
+ [![Gem Version](https://badge.fury.io/rb/dry-configurable.svg)][gem]
10
+ [![CI Status](https://github.com/dry-rb/dry-configurable/workflows/ci/badge.svg)][actions]
11
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/0276a97990e04eb0ac722b3e7f3620b5)][codacy]
12
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/0276a97990e04eb0ac722b3e7f3620b5)][codacy]
13
+ [![Inline docs](http://inch-ci.org/github/dry-rb/dry-configurable.svg?branch=master)][inchpages]
14
14
 
15
- ## Installation
16
-
17
- Add this line to your application's Gemfile:
18
-
19
- ```ruby
20
- gem 'dry-configurable'
21
- ```
22
-
23
- And then execute:
24
-
25
- ```sh
26
- $ bundle
27
- ```
15
+ ## Links
28
16
 
29
- Or install it yourself as:
17
+ * [User documentation](http://dry-rb.org/gems/dry-configurable)
18
+ * [API documentation](http://rubydoc.info/gems/dry-configurable)
30
19
 
31
- ```sh
32
- $ gem install dry-configurable
33
- ```
20
+ ## Supported Ruby versions
34
21
 
35
- ## Links
22
+ This library officially supports the following Ruby versions:
36
23
 
37
- * [Documentation](http://dry-rb.org/gems/dry-configurable)
24
+ * MRI >= `2.4`
25
+ * jruby >= `9.2`
38
26
 
39
27
  ## License
40
28
 
@@ -1,29 +1,38 @@
1
- require File.expand_path('../lib/dry/configurable/version', __FILE__)
1
+ # frozen_string_literal: true
2
+ # this file is managed by dry-rb/devtools project
3
+
4
+ lib = File.expand_path('lib', __dir__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ require 'dry/configurable/version'
2
7
 
3
8
  Gem::Specification.new do |spec|
4
9
  spec.name = 'dry-configurable'
5
- spec.version = Dry::Configurable::VERSION
6
- spec.authors = ['Andy Holland']
7
- spec.email = ['andyholland1991@aol.com']
8
- spec.summary = 'A mixin to add configuration functionality to your classes'
9
- spec.homepage = 'https://github.com/dry-rb/dry-configurable'
10
+ spec.authors = ["Andy Holland"]
11
+ spec.email = ["andyholland1991@aol.com"]
10
12
  spec.license = 'MIT'
13
+ spec.version = Dry::Configurable::VERSION.dup
11
14
 
12
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|bin)/}) }
13
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.summary = "A mixin to add configuration functionality to your classes"
16
+ spec.description = spec.summary
17
+ spec.homepage = 'https://dry-rb.org/gems/dry-configurable'
18
+ spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md", "dry-configurable.gemspec", "lib/**/*"]
19
+ spec.bindir = 'bin'
20
+ spec.executables = []
15
21
  spec.require_paths = ['lib']
16
22
 
17
- spec.metadata = {
18
- 'source_code_uri' => 'https://github.com/dry-rb/dry-configurable',
19
- 'changelog_uri' => 'https://github.com/dry-rb/dry-configurable/blob/master/CHANGELOG.md'
20
- }
23
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
24
+ spec.metadata['changelog_uri'] = 'https://github.com/dry-rb/dry-configurable/blob/master/CHANGELOG.md'
25
+ spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-configurable'
26
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-configurable/issues'
27
+
28
+ spec.required_ruby_version = ">= 2.4.0"
21
29
 
22
- spec.required_ruby_version = ">= 2.3.0"
23
- spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
24
- spec.add_runtime_dependency 'dry-core', '~> 0.4', '>= 0.4.7'
30
+ # to update dependencies edit project.yml
31
+ spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
32
+ spec.add_runtime_dependency "dry-core", "~> 0.4", ">= 0.4.7"
33
+ spec.add_runtime_dependency "dry-equalizer", "~> 0.2"
25
34
 
26
- spec.add_development_dependency 'bundler'
27
- spec.add_development_dependency 'rake'
28
- spec.add_development_dependency 'rspec'
35
+ spec.add_development_dependency "bundler"
36
+ spec.add_development_dependency "rake"
37
+ spec.add_development_dependency "rspec"
29
38
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/configurable'
@@ -1,10 +1,13 @@
1
- require 'dry/core/constants'
2
- require 'dry/configurable/settings'
3
- require 'dry/configurable/error'
4
- require 'dry/configurable/version'
1
+ # frozen_string_literal: true
2
+
3
+ require 'concurrent/array'
4
+
5
+ require 'dry/configurable/constants'
6
+ require 'dry/configurable/class_methods'
7
+ require 'dry/configurable/instance_methods'
8
+ require 'dry/configurable/config'
9
+ require 'dry/configurable/setting'
5
10
 
6
- # A collection of micro-libraries, each intended to encapsulate
7
- # a common task in Ruby
8
11
  module Dry
9
12
  # A simple configuration mixin
10
13
  #
@@ -40,151 +43,22 @@ module Dry
40
43
  #
41
44
  # @api public
42
45
  module Configurable
43
- include Dry::Core::Constants
44
-
45
- module ClassMethods
46
- # @private
47
- def self.extended(base)
48
- base.instance_exec do
49
- @settings = Settings.new
50
- end
51
- end
52
-
53
- # Add a setting to the configuration
54
- #
55
- # @param [Mixed] key
56
- # The accessor key for the configuration value
57
- # @param [Mixed] default
58
- # The default config value
59
- #
60
- # @yield
61
- # If a block is given, it will be evaluated in the context of
62
- # and new configuration class, and bound as the default value
63
- #
64
- # @return [Dry::Configurable::Config]
65
- #
66
- # @api public
67
- def setting(key, value = Undefined, options = Undefined, &block)
68
- extended = singleton_class < Configurable
69
- raise_already_defined_config(key) if _settings.config_defined?
70
-
71
- setting = _settings.add(key, value, options, &block)
72
-
73
- if setting.reader?
74
- readers = extended ? singleton_class : self
75
- readers.send(:define_method, setting.name) { config[setting.name] }
76
- end
77
- end
78
-
79
- # Return an array of setting names
80
- #
81
- # @return [Set]
82
- #
83
- # @api public
84
- def settings
85
- _settings.names
86
- end
87
-
88
- # @private no, really...
89
- def _settings
90
- @settings
91
- end
92
-
93
- private
94
-
95
- # @private
96
- def raise_already_defined_config(key)
97
- raise AlreadyDefinedConfig,
98
- "Cannot add setting +#{key}+, #{self} is already configured"
99
- end
100
-
101
- # @private
102
- def inherited(subclass)
103
- parent = self
104
- subclass.instance_exec do
105
- @settings = parent._settings.dup
106
- end
107
-
108
- if singleton_class < Configurable
109
- parent_config = @config
110
- subclass.instance_exec do
111
- @config = _settings.create_config
112
- @config.define!(parent_config.to_h) if parent_config.defined?
113
- end
114
- end
115
-
116
- super
117
- end
118
- end
119
-
120
- class << self
121
- # @private
122
- def extended(base)
123
- base.extend(ClassMethods)
124
- base.class_eval do
125
- @config = _settings.create_config
126
- end
127
- end
128
-
129
- # @private
130
- def included(base)
131
- base.extend(ClassMethods)
132
- end
133
- end
134
-
135
- # @private
136
- def initialize(*)
137
- @config = self.class._settings.create_config
46
+ # @api private
47
+ def self.extended(klass)
138
48
  super
49
+ klass.extend(ClassMethods)
139
50
  end
140
51
 
141
- # Return configuration
142
- #
143
- # @return [Dry::Configurable::Config]
144
- #
145
- # @api public
146
- def config
147
- return @config if @config.defined?
148
- @config.define!
149
- end
150
-
151
- # Return configuration
152
- #
153
- # @yield [Dry::Configuration::Config]
154
- #
155
- # @return [Dry::Configurable::Config]
156
- #
157
- # @api public
158
- def configure
159
- raise FrozenConfig, 'Cannot modify frozen config' if frozen?
160
- yield(config) if block_given?
161
- self
162
- end
163
-
164
- # Finalize and freeze configuration
165
- #
166
- # @return [Dry::Configurable::Config]
167
- #
168
- # @api public
169
- def finalize!
170
- freeze
171
- config.finalize!
172
- end
173
-
174
- # @api public
175
- def dup
176
- super.tap do |copy|
177
- copy.instance_variable_set(:@config, config.dup)
178
- end
179
- end
52
+ # @api private
53
+ def self.included(klass)
54
+ super
55
+ klass.class_eval do
56
+ extend(ClassMethods)
57
+ include(InstanceMethods)
180
58
 
181
- # @api public
182
- def clone
183
- if frozen?
184
- super
185
- else
186
- super.tap do |copy|
187
- copy.instance_variable_set(:@config, config.dup)
59
+ class << self
60
+ undef :config
61
+ undef :configure
188
62
  end
189
63
  end
190
64
  end