dry-configurable 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/dry/configurable.rb +8 -3
- data/lib/dry/configurable/test_interface.rb +22 -0
- data/lib/dry/configurable/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/shared_examples/configurable.rb +20 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51611822b7af9f064ab0b52e8708bf06351d1fba
|
4
|
+
data.tar.gz: ad9380c1994564966bd5caaa521026807b3a5a1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54182d4a1f47f5e2307cf1ee04edf5143495677767d731b23125a2c2a5fc5bff7d596736b0d238e6109b27cfa5510b525e0a7a4e10b2c30ab57f707af1cd2b92
|
7
|
+
data.tar.gz: 345a79f1ac2c33978fa8d608c96772e1cadf94083bc21bae654dc5e7c2004f7546f7d5c36ced4cd6ecccbf38722ba0592025aba64ede30c662d975a569277d1f
|
data/README.md
CHANGED
data/lib/dry/configurable.rb
CHANGED
@@ -50,9 +50,7 @@ module Dry
|
|
50
50
|
# @api public
|
51
51
|
def config
|
52
52
|
return @_config if defined?(@_config)
|
53
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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.
|
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:
|
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
|