dry-configurable 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4cbef88b095851ec643863da9c0fd42cc5cf54f
4
- data.tar.gz: bde6842ae91242766940d9304d6ac82c0ceaabec
3
+ metadata.gz: 51611822b7af9f064ab0b52e8708bf06351d1fba
4
+ data.tar.gz: ad9380c1994564966bd5caaa521026807b3a5a1a
5
5
  SHA512:
6
- metadata.gz: f8233d5a3b57bda025a6cd5492f805201c7cdbc8695dc5c664fe6aef0f07bdb08a3732cc8ce5747ea01b0f0acdb3e9967760ee10a6d3f0f0c06ae0ddc621b76e
7
- data.tar.gz: f865d739bd8f32ca49c208ca0291a463d71dfde39e67b7c8a85e4489150a8a3560b853d8093b9413859e3bbe24cfe43a888281c3f03b638053de860c1176df78
6
+ metadata.gz: 54182d4a1f47f5e2307cf1ee04edf5143495677767d731b23125a2c2a5fc5bff7d596736b0d238e6109b27cfa5510b525e0a7a4e10b2c30ab57f707af1cd2b92
7
+ data.tar.gz: 345a79f1ac2c33978fa8d608c96772e1cadf94083bc21bae654dc5e7c2004f7546f7d5c36ced4cd6ecccbf38722ba0592025aba64ede30c662d975a569277d1f
data/README.md CHANGED
@@ -36,6 +36,10 @@ App.config.database.dsn
36
36
  App.config.adapter # => nil
37
37
  ```
38
38
 
39
+ ## Links
40
+
41
+ * [Documentation](http://dry-rb.org/gems/dry-configurable)
42
+
39
43
  ## License
40
44
 
41
45
  See `LICENSE` file.
@@ -50,9 +50,7 @@ module Dry
50
50
  # @api public
51
51
  def config
52
52
  return @_config if defined?(@_config)
53
- @_config_mutex.synchronize do
54
- @_config ||= ::Dry::Configurable::Config.create(_settings) unless _settings.empty?
55
- end
53
+ create_config
56
54
  end
57
55
 
58
56
  # Return configuration
@@ -118,5 +116,12 @@ module Dry
118
116
  config_klass.instance_eval(&block)
119
117
  config_klass.config
120
118
  end
119
+
120
+ # @private
121
+ def create_config
122
+ @_config_mutex.synchronize do
123
+ @_config = ::Dry::Configurable::Config.create(_settings) unless _settings.empty?
124
+ end
125
+ end
121
126
  end
122
127
  end
@@ -0,0 +1,22 @@
1
+ module Dry
2
+ module Configurable
3
+ # Methods meant to be used in a testing scenario
4
+ module TestInterface
5
+ # Resets configuration to default values
6
+ #
7
+ # @return [Dry::Configurable::Config]
8
+ #
9
+ # @api public
10
+ def reset_config
11
+ create_config
12
+ end
13
+ end
14
+
15
+ # Mixes in test interface into the configurable module
16
+ #
17
+ # @api public
18
+ def enable_test_interface
19
+ extend Dry::Configurable::TestInterface
20
+ end
21
+ end
22
+ end
@@ -1,6 +1,6 @@
1
1
  module Dry
2
2
  module Configurable
3
3
  # @api public
4
- VERSION = '0.5.0'.freeze
4
+ VERSION = '0.6.0'.freeze
5
5
  end
6
6
  end
@@ -85,6 +85,7 @@ RSpec.configure do |config|
85
85
  end
86
86
 
87
87
  require 'dry/configurable'
88
+ require 'dry/configurable/test_interface'
88
89
 
89
90
  Dir[Pathname(__FILE__).dirname.join('support/**/*.rb').to_s].each do |file|
90
91
  require file
@@ -242,5 +242,25 @@ RSpec.shared_examples 'a configurable class' do
242
242
  end
243
243
  end
244
244
  end
245
+
246
+ context 'Test Interface' do
247
+ before { klass.enable_test_interface }
248
+
249
+ describe 'reset_config' do
250
+ before do
251
+ klass.setting :dsn, nil
252
+
253
+ klass.configure do |config|
254
+ config.dsn = 'sqlite:memory'
255
+ end
256
+
257
+ klass.reset_config
258
+ end
259
+
260
+ it 'resets configuration to default values' do
261
+ expect(klass.config.dsn).to be_nil
262
+ end
263
+ end
264
+ end
245
265
  end
246
266
  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.5.0
4
+ version: 0.6.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: 2016-12-21 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -87,6 +87,7 @@ files:
87
87
  - lib/dry/configurable.rb
88
88
  - lib/dry/configurable/config.rb
89
89
  - lib/dry/configurable/config/value.rb
90
+ - lib/dry/configurable/test_interface.rb
90
91
  - lib/dry/configurable/version.rb
91
92
  - rakelib/rubocop.rake
92
93
  - spec/integration/configurable_spec.rb