dry-configurable 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +1 -1
- data/dry-configurable.gemspec +1 -1
- data/lib/dry/configurable/config.rb +9 -6
- data/lib/dry/configurable/instance_methods.rb +1 -3
- data/lib/dry/configurable/methods.rb +2 -4
- data/lib/dry/configurable/setting.rb +15 -6
- data/lib/dry/configurable/settings.rb +6 -0
- data/lib/dry/configurable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b464e3a14e23a75467fc56883a5e222ad96139fee156972e58729607113cba55
|
4
|
+
data.tar.gz: 599d39ad241c3a6c17d27dd3ea8be2d94c1821a1c23ca9dea675126ba6c05ca6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d306539d687ef4dc2ee1a999008ab3ead0f466cef01cc17b0122bc088d503da4515b906fa1d26449a4c1dd57b82d39cfd2558c4734061025fb6954383364ee3
|
7
|
+
data.tar.gz: 421f2b5bc4a89b155d889ee4305183a3f97c42ab74db8cd9c41fecbccbb0f11ff739a4a01afa780da4291bf3404e6ed87c224093ee08f8de706ce46d30b39da8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,39 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 0.15.0 2022-04-21
|
4
|
+
|
5
|
+
|
6
|
+
### Changed
|
7
|
+
|
8
|
+
- The `finalize!` method (as class or instance method, depending on whether you extend or include `Dry::Configurable` respectively) now accepts a boolean `freeze_values:` argument, which if true, will recursively freeze all config values in addition to the `config` itself. (#105 by @ojab)
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
class MyConfigurable
|
12
|
+
include Dry::Configurable
|
13
|
+
|
14
|
+
setting :db, default: "postgre"
|
15
|
+
end
|
16
|
+
|
17
|
+
my_obj = MyConfigurable.new
|
18
|
+
my_obj.finalize!(freeze_values: true)
|
19
|
+
my_obj.config.db << "sql" # Will raise FrozenError
|
20
|
+
```
|
21
|
+
- `Dry::Configurable::Config#update` will set hashes as values for non-nested settings (#131 by @ojab)
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class MyConfigurable
|
25
|
+
extend Dry::Configurable
|
26
|
+
|
27
|
+
setting :sslcert, constructor: ->(v) { v&.values_at(:pem, :pass)&.join }
|
28
|
+
end
|
29
|
+
|
30
|
+
MyConfigurable.config.update(sslcert: {pem: "cert", pass: "qwerty"})
|
31
|
+
MyConfigurable.config.sslcert # => "certqwerty"
|
32
|
+
```
|
33
|
+
- `Dry::Configurable::Config#update` will accept any values implicitly convertible to hash via `#to_hash` (#133 by @timriley)
|
34
|
+
|
35
|
+
[Compare v0.14.0...v0.15.0](https://github.com/dry-rb/dry-configurable/compare/v0.14.0...v0.15.0)
|
36
|
+
|
3
37
|
## 0.14.0 2022-01-14
|
4
38
|
|
5
39
|
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
[![CI Status](https://github.com/dry-rb/dry-configurable/workflows/ci/badge.svg)][actions]
|
12
12
|
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/0276a97990e04eb0ac722b3e7f3620b5)][codacy]
|
13
13
|
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/0276a97990e04eb0ac722b3e7f3620b5)][codacy]
|
14
|
-
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-configurable.svg?branch=
|
14
|
+
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-configurable.svg?branch=main)][inchpages]
|
15
15
|
|
16
16
|
## Links
|
17
17
|
|
data/dry-configurable.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
25
|
-
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-configurable/blob/
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-configurable/blob/main/CHANGELOG.md"
|
26
26
|
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-configurable"
|
27
27
|
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-configurable/issues"
|
28
28
|
|
@@ -50,16 +50,19 @@ module Dry
|
|
50
50
|
|
51
51
|
# Update config with new values
|
52
52
|
#
|
53
|
-
# @param values [Hash] A hash with new values
|
53
|
+
# @param values [Hash, #to_hash] A hash with new values
|
54
54
|
#
|
55
55
|
# @return [Config]
|
56
56
|
#
|
57
57
|
# @api public
|
58
58
|
def update(values)
|
59
59
|
values.each do |key, value|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
if self[key].is_a?(self.class)
|
61
|
+
unless value.respond_to?(:to_hash)
|
62
|
+
raise ArgumentError, "#{value.inspect} is not a valid setting value"
|
63
|
+
end
|
64
|
+
|
65
|
+
self[key].update(value.to_hash)
|
63
66
|
else
|
64
67
|
self[key] = value
|
65
68
|
end
|
@@ -81,8 +84,8 @@ module Dry
|
|
81
84
|
alias_method :to_h, :values
|
82
85
|
|
83
86
|
# @api private
|
84
|
-
def finalize!
|
85
|
-
_settings.
|
87
|
+
def finalize!(freeze_values: false)
|
88
|
+
_settings.finalize!(freeze_values: freeze_values)
|
86
89
|
freeze
|
87
90
|
end
|
88
91
|
|
@@ -21,10 +21,8 @@ module Dry
|
|
21
21
|
# @return [Dry::Configurable::Config]
|
22
22
|
#
|
23
23
|
# @api public
|
24
|
-
def finalize!
|
25
|
-
|
26
|
-
|
27
|
-
config.finalize!
|
24
|
+
def finalize!(freeze_values: false)
|
25
|
+
config.finalize!(freeze_values: freeze_values)
|
28
26
|
self
|
29
27
|
end
|
30
28
|
end
|
@@ -84,8 +84,12 @@ module Dry
|
|
84
84
|
|
85
85
|
# @api private
|
86
86
|
def value
|
87
|
-
@value
|
87
|
+
return @value if evaluated?
|
88
|
+
|
89
|
+
@value = constructor[Undefined.coalesce(input, default, nil)]
|
88
90
|
end
|
91
|
+
alias_method :evaluate, :value
|
92
|
+
private :evaluate
|
89
93
|
|
90
94
|
# @api private
|
91
95
|
def evaluated?
|
@@ -102,6 +106,16 @@ module Dry
|
|
102
106
|
with(input: Undefined)
|
103
107
|
end
|
104
108
|
|
109
|
+
# @api private
|
110
|
+
def finalize!(freeze_values: false)
|
111
|
+
if value.is_a?(Config)
|
112
|
+
value.finalize!(freeze_values: freeze_values)
|
113
|
+
elsif freeze_values
|
114
|
+
value.freeze
|
115
|
+
end
|
116
|
+
freeze
|
117
|
+
end
|
118
|
+
|
105
119
|
# @api private
|
106
120
|
def with(new_opts)
|
107
121
|
self.class.new(name, input: input, default: default, **options, **new_opts)
|
@@ -149,11 +163,6 @@ module Dry
|
|
149
163
|
@value = source.value.dup if source.evaluated?
|
150
164
|
end
|
151
165
|
end
|
152
|
-
|
153
|
-
# @api private
|
154
|
-
def evaluate
|
155
|
-
@value = constructor[Undefined.coalesce(input, default, nil)]
|
156
|
-
end
|
157
166
|
end
|
158
167
|
end
|
159
168
|
end
|
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.
|
4
|
+
version: 0.15.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: 2022-
|
11
|
+
date: 2022-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -111,7 +111,7 @@ licenses:
|
|
111
111
|
- MIT
|
112
112
|
metadata:
|
113
113
|
allowed_push_host: https://rubygems.org
|
114
|
-
changelog_uri: https://github.com/dry-rb/dry-configurable/blob/
|
114
|
+
changelog_uri: https://github.com/dry-rb/dry-configurable/blob/main/CHANGELOG.md
|
115
115
|
source_code_uri: https://github.com/dry-rb/dry-configurable
|
116
116
|
bug_tracker_uri: https://github.com/dry-rb/dry-configurable/issues
|
117
117
|
post_install_message:
|