dry-configurable 0.11.1 → 0.11.6

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: d6c2b78240f829b83467c0edd12a5c4dc59d4d7b0fdb5aa9e44fdfc5e3031e13
4
- data.tar.gz: 506974ab79b93359fbac5305fa76860f13b13047dd85a76dffbbdebc500d2d93
3
+ metadata.gz: d76fbe81b58bc0a6d0e5abb5f135e32e6eb7f47533af60864a09e0143b3ea66c
4
+ data.tar.gz: 33f74bd69c1f030477088d32e80024969983e8dd793c58c89264828edc207a90
5
5
  SHA512:
6
- metadata.gz: 4e1bf6f3ea8ebd9bae2d0bd759cd3f81fd591d8df3a11e675b23acc54f1228ec3311bdab3c04f6b85e5db01ca718d1ed64b2347fa2bcbb3d439c127a6efdfe39
7
- data.tar.gz: 2ff1ff49ddee94891d5e920e5b48c2c4a5d50d7a2e56c4c4df7c68b46cd61c4270ee375ad6c5a9d6b95f4ca8b01b4d4dd397e2f350a4d6aa584c0d3d87e4442c
6
+ metadata.gz: aef6696e55e9ec56e46fabc857db9f1c2c8e266efad943844faf574d2d7d224829ca14457f66c8082f016d4cbdcb7f6bc9a1f33f641c743621c3b998d2f604d4
7
+ data.tar.gz: 11ab00f69b7c172d23d6de19a2f0a208bbd83ecd91b865cb591d18df0f91fd4578d487fb2acd71a88e4b89477a17e602816999847cad4fc0671139aa68e11d00
@@ -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...master](https://github.com/dry-rb/dry-configurable/compare/v0.11.0...master)
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
 
@@ -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
@@ -43,7 +43,7 @@ module Dry
43
43
 
44
44
  default, opts = args
45
45
 
46
- node = [:setting, [name, default, opts == default ? EMPTY_HASH : opts]]
46
+ node = [:setting, [name.to_sym, default, opts == default ? EMPTY_HASH : opts]]
47
47
 
48
48
  if block
49
49
  if block.arity.zero?
@@ -6,6 +6,7 @@ module Dry
6
6
  # @api public
7
7
  module Configurable
8
8
  Error = Class.new(::StandardError)
9
+ AlreadyIncluded = ::Class.new(Error)
9
10
  FrozenConfig = ::Class.new(Error)
10
11
  end
11
12
  end
@@ -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
 
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  module Configurable
5
5
  # @api public
6
- VERSION = '0.11.1'
6
+ VERSION = '0.11.6'
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.1
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-02-18 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby