dry-config 1.2.1 → 1.2.2
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 +4 -4
- data/lib/dry/config/base.rb +12 -2
- data/lib/dry/config/version.rb +1 -1
- data/spec/dry/config/base_spec.rb +28 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1b2402d421af2bd536b7fa28342000bcdbb71e9
|
4
|
+
data.tar.gz: ad9ec289bc4aa3af5ca980ccd1bfdb046818a689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3ba6e99b1661bb39cdcc980031245739f0899fd51ade6cea8cf61e6f60ad91c1ae228f7fb1585a16f3f0d9f203dd7cd3bee6ea6f2fb5cdb1df7be5830b8f80
|
7
|
+
data.tar.gz: 99dfa4d86675714763b8ebc9ad587ebfee8c5b2698e7ae4598e09264ce0cb0a1bd012f29feb6e24506f42f1d2d61b66ec306a36a30f87ffa78b2a1d1fd037260
|
data/lib/dry/config/base.rb
CHANGED
@@ -17,6 +17,10 @@ module Dry
|
|
17
17
|
attr_reader :environment
|
18
18
|
attr_reader :filenames
|
19
19
|
|
20
|
+
extend Forwardable
|
21
|
+
def_delegators :@configuration, :each_key, :each_value, :each_pair, :each, :keys, :values
|
22
|
+
|
23
|
+
|
20
24
|
def initialize(options = {})
|
21
25
|
@options = {
|
22
26
|
interpolation: true,
|
@@ -134,18 +138,24 @@ module Dry
|
|
134
138
|
nil
|
135
139
|
end
|
136
140
|
|
137
|
-
# configuration hash delegation
|
141
|
+
# configuration hash delegation with option based symbolization
|
138
142
|
def [] key
|
139
143
|
key = key.to_sym if symbolize?
|
140
144
|
@configuration[key]
|
141
145
|
end
|
142
146
|
|
143
|
-
# configuration hash delegation
|
147
|
+
# configuration hash delegation with option based symbolization
|
144
148
|
def []=(key, value)
|
145
149
|
key = key.to_sym if symbolize?
|
146
150
|
@configuration[key] = value
|
147
151
|
end
|
148
152
|
|
153
|
+
# configuration hash delegation with option based symbolization
|
154
|
+
def include?(key)
|
155
|
+
key = key.to_sym if symbolize?
|
156
|
+
@configuration.include? key
|
157
|
+
end
|
158
|
+
|
149
159
|
def symbolize?
|
150
160
|
@options[:symbolize]
|
151
161
|
end
|
data/lib/dry/config/version.rb
CHANGED
@@ -43,18 +43,37 @@ describe Dry::Config::Base do
|
|
43
43
|
expect(acmeConfig.production).to be_nil
|
44
44
|
end
|
45
45
|
|
46
|
+
context 'hash delegation' do
|
47
|
+
it 'manupulated delegated methods setter/getter/include?' do
|
48
|
+
acmeConfig.clear
|
49
|
+
acmeConfig.load!(nil, config_file_path)
|
50
|
+
expect(acmeConfig.symbolize?).to be_truthy
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
acmeConfig['foo'] = 'bar'
|
53
|
+
expect(acmeConfig.configuration['foo']).to be_nil # no symbolization on direct access
|
54
|
+
expect(acmeConfig['foo']).to eq 'bar' # symbolization based on options
|
55
|
+
|
56
|
+
expect(acmeConfig.configuration[:foo]).to eq 'bar' # setter symbolizes, this works
|
57
|
+
expect(acmeConfig[:foo]).to eq 'bar'
|
58
|
+
|
59
|
+
expect(acmeConfig.include? 'foo').to be_truthy
|
60
|
+
expect(acmeConfig.include? :foo).to be_truthy
|
61
|
+
end
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
|
63
|
+
it 'direct delegation' do
|
64
|
+
acmeConfig.clear
|
65
|
+
acmeConfig.load!(nil, config_file_path)
|
66
|
+
expect(acmeConfig.symbolize?).to be_truthy
|
55
67
|
|
56
|
-
|
57
|
-
|
68
|
+
expect(acmeConfig.respond_to? :each_key).to be_truthy
|
69
|
+
expect(acmeConfig.respond_to? :each_value).to be_truthy
|
70
|
+
expect(acmeConfig.respond_to? :each_pair).to be_truthy
|
71
|
+
expect(acmeConfig.respond_to? :each).to be_truthy
|
72
|
+
expect(acmeConfig.respond_to? :keys).to be_truthy
|
73
|
+
expect(acmeConfig.respond_to? :values).to be_truthy
|
74
|
+
|
75
|
+
# acmeConfig.each_key { |key| puts key }
|
76
|
+
end
|
58
77
|
end
|
59
78
|
|
60
79
|
context 'when loading a single configuration file' do
|