dry-configurable 0.11.0 → 0.11.1

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: d220ee0a9d75b6b400a98b8165b32f9c3fe3fbfdc4661f36e8a99a6a36181cb7
4
- data.tar.gz: 3c22814973a66b5ea08efaa14c6c8dc2130b7a8c20e48167e400aa51e66426e3
3
+ metadata.gz: d6c2b78240f829b83467c0edd12a5c4dc59d4d7b0fdb5aa9e44fdfc5e3031e13
4
+ data.tar.gz: 506974ab79b93359fbac5305fa76860f13b13047dd85a76dffbbdebc500d2d93
5
5
  SHA512:
6
- metadata.gz: 44819f0abbc69555c660df2cf1e777bd0a6ca9bcccc9fbbd9c1198983e2739e47530527f7d07b737432a4429fe1243d28d62625992bb76f91e1437bab441eb42
7
- data.tar.gz: 28001d7d843d4e70bbcc4a57332400b868fd385345b8a5977b82c713fc2b9f21f4a5e5746fee630e8f6d83990144943b7b7b1e604291a91096fd25971982c91e
6
+ metadata.gz: 4e1bf6f3ea8ebd9bae2d0bd759cd3f81fd591d8df3a11e675b23acc54f1228ec3311bdab3c04f6b85e5db01ca718d1ed64b2347fa2bcbb3d439c127a6efdfe39
7
+ data.tar.gz: 2ff1ff49ddee94891d5e920e5b48c2c4a5d50d7a2e56c4c4df7c68b46cd61c4270ee375ad6c5a9d6b95f4ca8b01b4d4dd397e2f350a4d6aa584c0d3d87e4442c
@@ -1,5 +1,16 @@
1
1
  ## unreleased
2
2
 
3
+
4
+ ### Fixed
5
+
6
+ - You can use `:settings` as a config key again (issue #80) (@solnic)
7
+ - Setting value is lazy-evaluated now, which fixes some cases where a constructor could crash with a `nil` value (@solnic)
8
+
9
+
10
+ [Compare v0.11.0...master](https://github.com/dry-rb/dry-configurable/compare/v0.11.0...master)
11
+
12
+ ## 0.11.0 2020-02-15
13
+
3
14
  Complete rewrite of the library while keeping the public API intact. See #78 for a detailed overview.
4
15
 
5
16
  ### Changed
@@ -8,7 +19,7 @@ Complete rewrite of the library while keeping the public API intact. See #78 for
8
19
  - (internal) New low-level Setting and Config API (@solnic)
9
20
  - (internal) `config` objects use method_missing now (@solnic)
10
21
 
11
- [Compare v0.10.0...master](https://github.com/dry-rb/dry-configurable/compare/v0.10.0...master)
22
+ [Compare v0.10.0...v0.11.0](https://github.com/dry-rb/dry-configurable/compare/v0.10.0...v0.11.0)
12
23
 
13
24
  ## 0.10.0 2020-01-31
14
25
 
@@ -16,7 +16,7 @@ module Dry
16
16
  def inherited(klass)
17
17
  super
18
18
 
19
- parent_settings = (respond_to?(:config) ? config.settings : _settings)
19
+ parent_settings = (respond_to?(:config) ? config._settings : _settings)
20
20
 
21
21
  klass.instance_variable_set('@_settings', parent_settings)
22
22
  end
@@ -16,15 +16,15 @@ module Dry
16
16
  include Dry::Equalizer(:values)
17
17
 
18
18
  # @api private
19
- attr_reader :settings
19
+ attr_reader :_settings
20
20
 
21
21
  # @api private
22
- attr_reader :resolved
22
+ attr_reader :_resolved
23
23
 
24
24
  # @api private
25
25
  def initialize(settings)
26
- @settings = settings.dup
27
- @resolved = Concurrent::Map.new
26
+ @_settings = settings.dup
27
+ @_resolved = Concurrent::Map.new
28
28
  end
29
29
 
30
30
  # Get config value by a key
@@ -33,9 +33,9 @@ module Dry
33
33
  #
34
34
  # @return Config value
35
35
  def [](name)
36
- raise ArgumentError, "+#{name}+ is not a setting name" unless settings.key?(name)
36
+ raise ArgumentError, "+#{name}+ is not a setting name" unless _settings.key?(name)
37
37
 
38
- settings[name].value
38
+ _settings[name].value
39
39
  end
40
40
 
41
41
  # Set config value.
@@ -71,7 +71,7 @@ module Dry
71
71
  #
72
72
  # @api public
73
73
  def values
74
- settings
74
+ _settings
75
75
  .map { |setting| [setting.name, setting.value] }
76
76
  .map { |key, value| [key, value.is_a?(self.class) ? value.to_h : value] }
77
77
  .to_h
@@ -81,32 +81,32 @@ module Dry
81
81
 
82
82
  # @api private
83
83
  def finalize!
84
- settings.freeze
84
+ _settings.freeze
85
85
  freeze
86
86
  end
87
87
 
88
88
  # @api private
89
89
  def pristine
90
- self.class.new(settings.pristine)
90
+ self.class.new(_settings.pristine)
91
91
  end
92
92
 
93
93
  # @api private
94
94
  def respond_to_missing?(meth, include_private = false)
95
- super || settings.key?(resolve(meth))
95
+ super || _settings.key?(resolve(meth))
96
96
  end
97
97
 
98
98
  private
99
99
 
100
100
  # @api private
101
101
  def method_missing(meth, *args)
102
- setting = settings[resolve(meth)]
102
+ setting = _settings[resolve(meth)]
103
103
 
104
104
  super unless setting
105
105
 
106
106
  if setting.writer?(meth)
107
107
  raise FrozenConfig, 'Cannot modify frozen config' if frozen?
108
108
 
109
- settings << setting.with(input: args[0])
109
+ _settings << setting.with(input: args[0])
110
110
  else
111
111
  setting.value
112
112
  end
@@ -114,13 +114,13 @@ module Dry
114
114
 
115
115
  # @api private
116
116
  def resolve(meth)
117
- resolved.fetch(meth) { resolved[meth] = meth.to_s.tr('=', '').to_sym }
117
+ _resolved.fetch(meth) { _resolved[meth] = meth.to_s.tr('=', '').to_sym }
118
118
  end
119
119
 
120
120
  # @api private
121
121
  def initialize_copy(source)
122
122
  super
123
- @settings = source.settings.dup
123
+ @_settings = source._settings.dup
124
124
  end
125
125
  end
126
126
  end
@@ -63,7 +63,11 @@ module Dry
63
63
  @input = input.equal?(Undefined) ? default : input
64
64
  @default = default
65
65
  @options = options
66
- set!
66
+ end
67
+
68
+ # @api private
69
+ def value
70
+ @value ||= evaluate
67
71
  end
68
72
 
69
73
  # @api private
@@ -111,7 +115,7 @@ module Dry
111
115
  end
112
116
 
113
117
  # @api private
114
- def set!
118
+ def evaluate
115
119
  @value = constructor[input.equal?(Undefined) ? nil : input]
116
120
  end
117
121
  end
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  module Configurable
5
5
  # @api public
6
- VERSION = '0.11.0'
6
+ VERSION = '0.11.1'
7
7
  end
8
8
  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.11.0
4
+ version: 0.11.1
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-02-15 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby