dry-configurable 0.11.2 → 0.12.0

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: 65b62072b64448e9497df8793ee48ffe9054ab0d5aaae81155ae39261540699a
4
- data.tar.gz: 3c9d313e814c318fa2cda842893d6f6f2a10ca7f7782ef1754f2d13aeecd7082
3
+ metadata.gz: 102cb0a4fe42ebde6835f50b7e75826dbc4b98c78cca9fcee5c5863c1c47651f
4
+ data.tar.gz: f5da17ecfb79edfa42c0d6c9a0d05d3e4cce2297533ec3151afafc9e6d4151b3
5
5
  SHA512:
6
- metadata.gz: 9b4ef50f85d48ed7a428c5c982d9ecde8d099c054e4f9cacee8b391dbbe9484ac0a9a0c2d7225e0d131c6737afb32102d5d270cb15b5470f75550ecf30269121
7
- data.tar.gz: a7354981a2991f3cca99aa07490194aba880c68c6d7eb47c5365b5860722a3bbafba1dcceeeeb8bd12859742ad461f2ca9e18f92834fd60758ac3c2df95082b1
6
+ metadata.gz: 7d6dac8ebf7eddf6eb8b61da5cef0a434769270fc5ad2ab13ea7a4c5d093c047681b1bc85da4ba09190cfcf17ef023293dc4ccdb2f8dd2ac7eae19dbb4c69706
7
+ data.tar.gz: be0be051c79c2ef527d678cb9f839d6cabf40669b19864d38a735fe428a277068504897bd289baf69e0da26f470e35e0c2e73bc99f62dd16286fa7148a35572c
@@ -1,3 +1,65 @@
1
+ <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
+
3
+ ## 0.12.0 2020-12-26
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Setting values provided by defaults and/or pre-processor blocks are no longer accidentally memoized across instances of classes including Dry::Configurable (#99) (@timriley & @esparta)
9
+
10
+ ### Changed
11
+
12
+ - Instance behavior is now prepended, so that if you have your own `initialize`, calling `super` is no longer required (see #98 for more details) (@zabolotnov87)
13
+ - Switched to equalizer from dry-core (@solnic)
14
+
15
+ [Compare v0.11.6...v0.12.0](https://github.com/dry-rb/dry-configurable/compare/v0.11.6...v0.12.0)
16
+
17
+ ## 0.11.6 2020-06-22
18
+
19
+
20
+ ### Changed
21
+
22
+ - A meaningful error is raised when the extension is included more than once (issue #89 fixed via #94) (@landongrindheim)
23
+ - Evaluate setting input immediately when input is provided. This allows for earlier feedback from constructors designed to raise errors on invalid input (#95) (@timriley)
24
+
25
+ [Compare v0.11.5...v0.11.6](https://github.com/dry-rb/dry-configurable/compare/v0.11.5...v0.11.6)
26
+
27
+ ## 0.11.5 2020-03-23
28
+
29
+
30
+ ### Fixed
31
+
32
+ - 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)
33
+
34
+ ### Changed
35
+
36
+ - A meaningful error is raised when the extension is included more than once (issue #89 fixed via #94) (@landongrindheim)
37
+
38
+ [Compare v0.11.4...v0.11.5](https://github.com/dry-rb/dry-configurable/compare/v0.11.4...v0.11.5)
39
+
40
+ ## 0.11.4 2020-03-16
41
+
42
+
43
+ ### Fixed
44
+
45
+ - `Config#update` returns `self` again (issue #60 fixed via #92) (@solnic)
46
+
47
+ ### Changed
48
+
49
+ - `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)
50
+
51
+ [Compare v0.11.3...v0.11.4](https://github.com/dry-rb/dry-configurable/compare/v0.11.3...v0.11.4)
52
+
53
+ ## 0.11.3 2020-02-22
54
+
55
+
56
+ ### Fixed
57
+
58
+ - Retrieving settings by a string name works again (issue #82) (@waiting-for-dev)
59
+
60
+
61
+ [Compare v0.11.2...v0.11.3](https://github.com/dry-rb/dry-configurable/compare/v0.11.2...v0.11.3)
62
+
1
63
  ## 0.11.2 2020-02-20
2
64
 
3
65
 
data/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  This library officially supports the following Ruby versions:
23
23
 
24
- * MRI >= `2.4`
24
+ * MRI >= `2.5`
25
25
  * jruby >= `9.2`
26
26
 
27
27
  ## License
@@ -25,12 +25,11 @@ Gem::Specification.new do |spec|
25
25
  spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-configurable'
26
26
  spec.metadata['bug_tracker_uri'] = 'https://github.com/dry-rb/dry-configurable/issues'
27
27
 
28
- spec.required_ruby_version = ">= 2.4.0"
28
+ spec.required_ruby_version = ">= 2.5.0"
29
29
 
30
30
  # to update dependencies edit project.yml
31
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"
32
+ spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5.0"
34
33
 
35
34
  spec.add_development_dependency "bundler"
36
35
  spec.add_development_dependency "rake"
@@ -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,10 +52,12 @@ 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)
57
- include(InstanceMethods)
60
+ prepend(InstanceMethods)
58
61
 
59
62
  class << self
60
63
  undef :config
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'concurrent/map'
4
4
 
5
- require 'dry/equalizer'
5
+ require 'dry/core/equalizer'
6
6
 
7
7
  require 'dry/configurable/constants'
8
8
  require 'dry/configurable/errors'
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'set'
4
4
 
5
- require 'dry/equalizer'
5
+ require 'dry/core/equalizer'
6
6
 
7
7
  require 'dry/configurable/constants'
8
8
  require 'dry/configurable/config'
@@ -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
 
@@ -53,13 +53,25 @@ module Dry
53
53
  end
54
54
  end
55
55
 
56
+ # @api private
57
+ def self.clonable_value?(value)
58
+ CLONABLE_VALUE_TYPES.any? { |type| value.is_a?(type) }
59
+ end
60
+
56
61
  # @api private
57
62
  def initialize(name, input: Undefined, default: Undefined, **options)
58
63
  @name = name
59
64
  @writer_name = :"#{name}="
60
- @input = input.equal?(Undefined) ? default : input
65
+ @input = input
61
66
  @default = default
62
67
  @options = options
68
+
69
+ evaluate if input_defined?
70
+ end
71
+
72
+ # @api private
73
+ def input_defined?
74
+ !input.equal?(Undefined)
63
75
  end
64
76
 
65
77
  # @api private
@@ -67,6 +79,11 @@ module Dry
67
79
  @value ||= evaluate
68
80
  end
69
81
 
82
+ # @api private
83
+ def evaluated?
84
+ instance_variable_defined?(:@value)
85
+ end
86
+
70
87
  # @api private
71
88
  def nested(settings)
72
89
  Nested.new(name, input: settings, **options)
@@ -97,23 +114,20 @@ module Dry
97
114
  writer_name.equal?(meth)
98
115
  end
99
116
 
100
- # @api private
101
- def clonable_value?
102
- CLONABLE_VALUE_TYPES.any? { |type| value.is_a?(type) }
103
- end
104
-
105
117
  private
106
118
 
107
119
  # @api private
108
120
  def initialize_copy(source)
109
121
  super
110
- @value = source.value.dup if source.clonable_value?
122
+ @input = source.input.dup if Setting.clonable_value?(source.input)
123
+ @default = source.default.dup if Setting.clonable_value?(source.default)
124
+ @value = source.value.dup if source.evaluated? && Setting.clonable_value?(source.value)
111
125
  @options = source.options.dup
112
126
  end
113
127
 
114
128
  # @api private
115
129
  def evaluate
116
- @value = constructor[input.equal?(Undefined) ? nil : input]
130
+ @value = constructor[Undefined.coalesce(input, default, nil)]
117
131
  end
118
132
  end
119
133
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'concurrent/map'
4
4
 
5
- require 'dry/equalizer'
5
+ require 'dry/core/equalizer'
6
6
  require 'dry/configurable/constants'
7
7
 
8
8
  module Dry
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  module Configurable
5
5
  # @api public
6
- VERSION = '0.11.2'
6
+ VERSION = '0.12.0'
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.2
4
+ version: 0.12.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: 2020-02-20 00:00:00.000000000 Z
11
+ date: 2020-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -30,34 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.4'
33
+ version: '0.5'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.4.7
36
+ version: 0.5.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '0.4'
43
+ version: '0.5'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.4.7
47
- - !ruby/object:Gem::Dependency
48
- name: dry-equalizer
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '0.2'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '0.2'
46
+ version: 0.5.0
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: bundler
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ">="
144
130
  - !ruby/object:Gem::Version
145
- version: 2.4.0
131
+ version: 2.5.0
146
132
  required_rubygems_version: !ruby/object:Gem::Requirement
147
133
  requirements:
148
134
  - - ">="
149
135
  - !ruby/object:Gem::Version
150
136
  version: '0'
151
137
  requirements: []
152
- rubygems_version: 3.0.3
138
+ rubygems_version: 3.1.4
153
139
  signing_key:
154
140
  specification_version: 4
155
141
  summary: A mixin to add configuration functionality to your classes