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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39be9de9a8fa72ac20c65f44c1acd4841194e7a5
4
- data.tar.gz: 100bf923f66e6192f928d9ba1aa5b281f1e5fb2d
3
+ metadata.gz: e1b2402d421af2bd536b7fa28342000bcdbb71e9
4
+ data.tar.gz: ad9ec289bc4aa3af5ca980ccd1bfdb046818a689
5
5
  SHA512:
6
- metadata.gz: 552724072d2986a4cad3a0c7b79d8bf28b4fd7e4dade6f24f1d6436cf3d01ce10843a56ce34f95baaa272fed372ef4d2013a277c1545f3d907bebb99d87665c0
7
- data.tar.gz: 05e2dd79945c529363d84f68ec023a4af07a2ac93ea8287a6f56adf03c4f6890ea9e12a30465d2c0e020039914854a5bbac6f5749e9dd69e4ef4435288322e84
6
+ metadata.gz: ae3ba6e99b1661bb39cdcc980031245739f0899fd51ade6cea8cf61e6f60ad91c1ae228f7fb1585a16f3f0d9f203dd7cd3bee6ea6f2fb5cdb1df7be5830b8f80
7
+ data.tar.gz: 99dfa4d86675714763b8ebc9ad587ebfee8c5b2698e7ae4598e09264ce0cb0a1bd012f29feb6e24506f42f1d2d61b66ec306a36a30f87ffa78b2a1d1fd037260
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  module Config
3
- VERSION = '1.2.1'
3
+ VERSION = '1.2.2'
4
4
  end
5
5
  end
@@ -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
- it 'hash delegation to setter/getter' do
48
- acmeConfig.clear
49
- acmeConfig.load!(nil, config_file_path)
50
- expect(acmeConfig.symbolize?).to be_truthy
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
- 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
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
- expect(acmeConfig.configuration[:foo]).to eq 'bar' # setter symbolizes, this works
57
- expect(acmeConfig[:foo]).to eq 'bar'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ross