dry-configurable 0.13.0 → 0.14.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: 0b1292743d03212bcca735f18e876046b27cb3859a561a9b714704627542a324
4
- data.tar.gz: 5d9f334008b7d055bbcbadf21feb61dbef8888ed01cc877e54cd7f5959b46f48
3
+ metadata.gz: 90bd271135f8ccb892c1cf3afc448f92fe50587567725e860de78b4ed58bb57a
4
+ data.tar.gz: 8580ad144d2fa3e0189c65a9873282db49c8ddd7d5c349b0f4d6f292e7f675ce
5
5
  SHA512:
6
- metadata.gz: 1b9bbe538bd93cc27e87e7e97a83bd1f98757d776d215028b88bb8d8b085a2114c53b7f4e3ad1d77ae70b21d99652a7bbe65d978106f897e784374456cb615db
7
- data.tar.gz: 9fdeb06faf9888965037a364560c10364342731e7c825d56d4fd1cdeeb929992e201ef1f6fb3b14d4fb68ee037588e3a064a8f2236588d0417599e55df7a6a89
6
+ metadata.gz: b6613b8677ab724316dde1440ff0640021621d48eec1e0ca1125e28dfdb82bfd94800a3bf5d511fc704062dded24de5bd266012c7145028f2d2322a2837ad77c
7
+ data.tar.gz: 69a5d08bfbf53bc232ec8f0fb56186576fe1fe5128205d9597b87bccce750bc94256da9cd9644fa94b4e175f6f86911bad99e866f627e06f2386c29fbc89a634
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.14.0 2022-01-14
4
+
5
+
6
+ ### Changed
7
+
8
+ - Settings defined after an access to `config` will still be made available on that `config`. (#130 by @timriley)
9
+ - Cloneable settings are cloned immediately upon assignment. (#130 by @timriley)
10
+ - Changes to config values in parent classes after subclasses have already been created will not be propogated to those subclasses. Subclasses created _after_ config values have been changed in the parent _will_ receive those config values. (#130 by @timriley)
11
+
12
+ [Compare v0.13.0...v0.14.0](https://github.com/dry-rb/dry-configurable/compare/v0.13.0...v0.14.0)
13
+
3
14
  ## 0.13.0 2021-09-12
4
15
 
5
16
 
@@ -8,8 +19,8 @@
8
19
  - Added flags to determine whether to warn on the API usage deprecated in this release (see "Changed" section below). Set these to `false` to suppress the warnings. (#124 by @timriley)
9
20
 
10
21
  ```ruby
11
- Dry::Configurable.warn_on_setting_constructor_block = false
12
- Dry::Configurable.warn_on_setting_positional_default = false
22
+ Dry::Configurable.warn_on_setting_constructor_block false
23
+ Dry::Configurable.warn_on_setting_positional_default false
13
24
  ```
14
25
 
15
26
  ### Fixed
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  # dry-configurable [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
9
9
 
10
10
  [![Gem Version](https://badge.fury.io/rb/dry-configurable.svg)][gem]
11
- [![CI Status](https://github.com/dry-rb/dry-configurable/workflows/CI/badge.svg)][actions]
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
14
  [![Inline docs](http://inch-ci.org/github/dry-rb/dry-configurable.svg?branch=master)][inchpages]
@@ -22,8 +22,8 @@
22
22
 
23
23
  This library officially supports the following Ruby versions:
24
24
 
25
- * MRI `>= 2.6.0`
26
- * ~~jruby~~ `>= 9.3` (we are waiting for [2.6 support](https://github.com/jruby/jruby/issues/6161))
25
+ * MRI `>= 2.7.0`
26
+ * jruby `>= 9.3` (postponed until 2.7 is supported)
27
27
 
28
28
  ## License
29
29
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
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
 
29
- spec.required_ruby_version = ">= 2.6.0"
29
+ spec.required_ruby_version = ">= 2.7.0"
30
30
 
31
31
  # to update dependencies edit project.yml
32
32
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
@@ -13,12 +13,11 @@ module Dry
13
13
  include Methods
14
14
 
15
15
  # @api private
16
- def inherited(klass)
16
+ def inherited(subclass)
17
17
  super
18
18
 
19
- parent_settings = (respond_to?(:config) ? config._settings : _settings)
20
-
21
- klass.instance_variable_set("@_settings", parent_settings)
19
+ subclass.instance_variable_set("@_settings", _settings.dup)
20
+ subclass.instance_variable_set("@_config", config.dup) if respond_to?(:config)
22
21
  end
23
22
 
24
23
  # Add a setting to the configuration
@@ -71,6 +70,11 @@ module Dry
71
70
  #
72
71
  # @api public
73
72
  def config
73
+ # The _settings provided to the Config remain shared between the class and the
74
+ # Config. This allows settings defined _after_ accessing the config to become
75
+ # available in subsequent accesses to the config. The config is duped when
76
+ # subclassing to ensure it remains distinct between subclasses and parent classes
77
+ # (see `.inherited` above).
74
78
  @config ||= Config.new(_settings)
75
79
  end
76
80
 
@@ -23,7 +23,7 @@ module Dry
23
23
 
24
24
  # @api private
25
25
  def initialize(settings)
26
- @_settings = settings.dup
26
+ @_settings = settings
27
27
  @_resolved = Concurrent::Map.new
28
28
  end
29
29
 
@@ -12,7 +12,11 @@ module Dry
12
12
  module Initializer
13
13
  # @api private
14
14
  def initialize(*)
15
+ # Dup settings at time of initializing to ensure setting values are specific to
16
+ # this instance. This does mean that any settings defined on the class _after_
17
+ # initialization will not be available on the instance.
15
18
  @config = Config.new(self.class._settings.dup)
19
+
16
20
  super
17
21
  end
18
22
  ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
@@ -62,9 +62,17 @@ module Dry
62
62
  def initialize(name, input: Undefined, default: Undefined, **options)
63
63
  @name = name
64
64
  @writer_name = :"#{name}="
65
+ @options = options
66
+
67
+ # Setting collections (see `Settings`) are shared between the configurable class
68
+ # and its `config` object, so for cloneable individual settings, we duplicate
69
+ # their _values_ as early as possible to ensure no impact from unintended mutation
65
70
  @input = input
66
71
  @default = default
67
- @options = options
72
+ if cloneable?
73
+ @input = input.dup
74
+ @default = default.dup
75
+ end
68
76
 
69
77
  evaluate if input_defined?
70
78
  end
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  module Configurable
5
5
  # @api public
6
- VERSION = "0.13.0"
6
+ VERSION = "0.14.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.13.0
4
+ version: 0.14.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: 2021-09-12 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 2.6.0
125
+ version: 2.7.0
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="