dry-configurable 0.11.1 → 0.11.6
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 +57 -1
- data/lib/dry/configurable.rb +3 -0
- data/lib/dry/configurable/config.rb +3 -1
- data/lib/dry/configurable/dsl.rb +1 -1
- data/lib/dry/configurable/errors.rb +1 -0
- data/lib/dry/configurable/setting.rb +14 -5
- data/lib/dry/configurable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d76fbe81b58bc0a6d0e5abb5f135e32e6eb7f47533af60864a09e0143b3ea66c
|
4
|
+
data.tar.gz: 33f74bd69c1f030477088d32e80024969983e8dd793c58c89264828edc207a90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef6696e55e9ec56e46fabc857db9f1c2c8e266efad943844faf574d2d7d224829ca14457f66c8082f016d4cbdcb7f6bc9a1f33f641c743621c3b998d2f604d4
|
7
|
+
data.tar.gz: 11ab00f69b7c172d23d6de19a2f0a208bbd83ecd91b865cb591d18df0f91fd4578d487fb2acd71a88e4b89477a17e602816999847cad4fc0671139aa68e11d00
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,69 @@
|
|
1
1
|
## unreleased
|
2
2
|
|
3
3
|
|
4
|
+
### Changed
|
5
|
+
|
6
|
+
- A meaningful error is raised when the extension is included more than once (issue #89 fixed via #94) (@landongrindheim)
|
7
|
+
- Evaluate setting input immediately when input is provided. This allows for earlier feedback from constructors designed to raise errors on invalid input (#95) (@timriley)
|
8
|
+
|
9
|
+
[Compare v0.11.5...master](https://github.com/dry-rb/dry-configurable/compare/v0.11.5...master)
|
10
|
+
|
11
|
+
## 0.11.5 2020-03-23
|
12
|
+
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
- When settings are copied or cloned, unevaluated values will no longer be copied. This prevents unintended crashes when settings have constructors expecting a certain type of value, but that value is yet to be provided (Fixed via #87) (@timriley)
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
- A meaningful error is raised when the extension is included more than once (issue #89 fixed via #94) (@landongrindheim)
|
21
|
+
|
22
|
+
[Compare v0.11.4...v0.11.5](https://github.com/dry-rb/dry-configurable/compare/v0.11.4...v0.11.5)
|
23
|
+
|
24
|
+
## 0.11.4 2020-03-16
|
25
|
+
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
- `Config#update` returns `self` again (issue #60 fixed via #92) (@solnic)
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- `Setting#inspect` no longer uses its value - this could cause crashes when inspecting settings that are yet to have a value applied (e.g. when they have a constructor that expects a value to be present) (@timriley)
|
34
|
+
|
35
|
+
[Compare v0.11.3...v0.11.4](https://github.com/dry-rb/dry-configurable/compare/v0.11.3...v0.11.4)
|
36
|
+
|
37
|
+
## 0.11.3 2020-02-22
|
38
|
+
|
39
|
+
|
40
|
+
### Fixed
|
41
|
+
|
42
|
+
- Retrieving settings by a string name works again (issue #82) (@waiting-for-dev)
|
43
|
+
|
44
|
+
|
45
|
+
[Compare v0.11.2...v0.11.3](https://github.com/dry-rb/dry-configurable/compare/v0.11.2...v0.11.3)
|
46
|
+
|
47
|
+
## 0.11.2 2020-02-20
|
48
|
+
|
49
|
+
|
50
|
+
### Fixed
|
51
|
+
|
52
|
+
- Warning about redefined `Setting#value` is gone (@solnic)
|
53
|
+
|
54
|
+
|
55
|
+
[Compare v0.11.1...v0.11.2](https://github.com/dry-rb/dry-configurable/compare/v0.11.1...v0.11.2)
|
56
|
+
|
57
|
+
## 0.11.1 2020-02-18
|
58
|
+
|
59
|
+
|
4
60
|
### Fixed
|
5
61
|
|
6
62
|
- You can use `:settings` as a config key again (issue #80) (@solnic)
|
7
63
|
- Setting value is lazy-evaluated now, which fixes some cases where a constructor could crash with a `nil` value (@solnic)
|
8
64
|
|
9
65
|
|
10
|
-
[Compare v0.11.0...
|
66
|
+
[Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-configurable/compare/v0.11.0...v0.11.1)
|
11
67
|
|
12
68
|
## 0.11.0 2020-02-15
|
13
69
|
|
data/lib/dry/configurable.rb
CHANGED
@@ -7,6 +7,7 @@ require 'dry/configurable/class_methods'
|
|
7
7
|
require 'dry/configurable/instance_methods'
|
8
8
|
require 'dry/configurable/config'
|
9
9
|
require 'dry/configurable/setting'
|
10
|
+
require 'dry/configurable/errors'
|
10
11
|
|
11
12
|
module Dry
|
12
13
|
# A simple configuration mixin
|
@@ -51,6 +52,8 @@ module Dry
|
|
51
52
|
|
52
53
|
# @api private
|
53
54
|
def self.included(klass)
|
55
|
+
raise AlreadyIncluded if klass.include?(InstanceMethods)
|
56
|
+
|
54
57
|
super
|
55
58
|
klass.class_eval do
|
56
59
|
extend(ClassMethods)
|
@@ -33,6 +33,7 @@ module Dry
|
|
33
33
|
#
|
34
34
|
# @return Config value
|
35
35
|
def [](name)
|
36
|
+
name = name.to_sym
|
36
37
|
raise ArgumentError, "+#{name}+ is not a setting name" unless _settings.key?(name)
|
37
38
|
|
38
39
|
_settings[name].value
|
@@ -49,7 +50,7 @@ module Dry
|
|
49
50
|
|
50
51
|
# Update config with new values
|
51
52
|
#
|
52
|
-
# @param [Hash] A hash with new values
|
53
|
+
# @param values [Hash] A hash with new values
|
53
54
|
#
|
54
55
|
# @return [Config]
|
55
56
|
#
|
@@ -63,6 +64,7 @@ module Dry
|
|
63
64
|
self[key] = value
|
64
65
|
end
|
65
66
|
end
|
67
|
+
self
|
66
68
|
end
|
67
69
|
|
68
70
|
# Dump config into a hash
|
data/lib/dry/configurable/dsl.rb
CHANGED
@@ -13,7 +13,7 @@ module Dry
|
|
13
13
|
#
|
14
14
|
# @api private
|
15
15
|
class Setting
|
16
|
-
include Dry::Equalizer(:name, :value, :options)
|
16
|
+
include Dry::Equalizer(:name, :value, :options, inspect: false)
|
17
17
|
|
18
18
|
OPTIONS = %i[input default reader constructor settings].freeze
|
19
19
|
|
@@ -33,9 +33,6 @@ module Dry
|
|
33
33
|
# @api private
|
34
34
|
attr_reader :default
|
35
35
|
|
36
|
-
# @api private
|
37
|
-
attr_reader :value
|
38
|
-
|
39
36
|
# @api private
|
40
37
|
attr_reader :options
|
41
38
|
|
@@ -63,6 +60,13 @@ module Dry
|
|
63
60
|
@input = input.equal?(Undefined) ? default : input
|
64
61
|
@default = default
|
65
62
|
@options = options
|
63
|
+
|
64
|
+
evaluate if input_defined?
|
65
|
+
end
|
66
|
+
|
67
|
+
# @api private
|
68
|
+
def input_defined?
|
69
|
+
!input.equal?(Undefined)
|
66
70
|
end
|
67
71
|
|
68
72
|
# @api private
|
@@ -70,6 +74,11 @@ module Dry
|
|
70
74
|
@value ||= evaluate
|
71
75
|
end
|
72
76
|
|
77
|
+
# @api private
|
78
|
+
def evaluated?
|
79
|
+
instance_variable_defined?(:@value)
|
80
|
+
end
|
81
|
+
|
73
82
|
# @api private
|
74
83
|
def nested(settings)
|
75
84
|
Nested.new(name, input: settings, **options)
|
@@ -110,7 +119,7 @@ module Dry
|
|
110
119
|
# @api private
|
111
120
|
def initialize_copy(source)
|
112
121
|
super
|
113
|
-
@value = source.value.dup if source.clonable_value?
|
122
|
+
@value = source.value.dup if source.input_defined? && source.clonable_value?
|
114
123
|
@options = source.options.dup
|
115
124
|
end
|
116
125
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-configurable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Holland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|