cascading-configuration-hash 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/Interface.rb +86 -27
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb +5 -21
- data/lib/cascading-configuration-hash/{CascadingConfiguration → _private_/CascadingConfiguration/Hash/CompositingHash}/LocalConfigurationHash.rb +29 -2
- data/lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/CompositingHash.rb +246 -0
- data/lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/Interface/GettersSetters.rb +233 -0
- data/lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/ModuleSupportMethods.rb +29 -0
- data/lib/cascading-configuration-hash.rb +12 -23
- data/spec/CascadingConfiguration/Hash_spec.rb +2 -3
- data/spec/{CascadingConfiguration → _private_/CascadingConfiguration/Hash/CompositingHash}/LocalConfigurationHash_spec.rb +9 -9
- data/spec/_private_/CascadingConfiguration/Hash/CompositingHash_spec.rb +347 -0
- metadata +10 -28
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash/Instance.rb +0 -31
- data/lib/cascading-configuration-hash/CascadingConfiguration/CompositingHash.rb +0 -135
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/AccessorDefinitionMethods.rb +0 -149
- data/lib/cascading-configuration-hash/CascadingConfiguration/Hash/Interface/Instance.rb +0 -26
- data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/CompositingHash.rb +0 -79
- data/lib/cascading-configuration-hash/CascadingConfiguration/_private_/LocalConfigurationHash.rb +0 -31
- data/spec/CascadingConfiguration/CascadingCompositeHash_spec.rb +0 -416
- data/spec/CascadingConfiguration/Hash/AccessorDefinitionMethods_spec.rb +0 -30
@@ -0,0 +1,347 @@
|
|
1
|
+
|
2
|
+
require_relative '../../../../lib/cascading-configuration-hash.rb'
|
3
|
+
|
4
|
+
describe CascadingConfiguration::Hash::CompositingHash do
|
5
|
+
|
6
|
+
#########
|
7
|
+
# []= #
|
8
|
+
#########
|
9
|
+
|
10
|
+
it 'can add elements' do
|
11
|
+
|
12
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock01
|
13
|
+
include CascadingConfiguration::Variable
|
14
|
+
end
|
15
|
+
|
16
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock01A
|
17
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock01
|
18
|
+
end
|
19
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock01B
|
20
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock01A
|
21
|
+
end
|
22
|
+
|
23
|
+
ccv = CascadingConfiguration::Variable
|
24
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock01
|
25
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock01A
|
26
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock01B
|
27
|
+
configuration_name = :some_configuration
|
28
|
+
|
29
|
+
# Without super or sub composites
|
30
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
31
|
+
cascading_composite_hash[ :some_setting ] = :some_value
|
32
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
33
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
34
|
+
cascading_composite_hash[ :other_setting ] = :some_value
|
35
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
|
36
|
+
:other_setting => :some_value }
|
37
|
+
cascading_composite_hash.should == { :some_setting => :some_value,
|
38
|
+
:other_setting => :some_value }
|
39
|
+
|
40
|
+
# Super with a sub composite
|
41
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
42
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
43
|
+
sub_cascading_composite_hash.should == { :some_setting => :some_value,
|
44
|
+
:other_setting => :some_value }
|
45
|
+
sub_cascading_composite_hash[ :yet_another_setting ] = :some_value
|
46
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
47
|
+
sub_cascading_composite_hash.should == { :some_setting => :some_value,
|
48
|
+
:other_setting => :some_value,
|
49
|
+
:yet_another_setting => :some_value }
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
###########
|
54
|
+
# store #
|
55
|
+
###########
|
56
|
+
|
57
|
+
it 'can add elements' do
|
58
|
+
|
59
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock02
|
60
|
+
include CascadingConfiguration::Variable
|
61
|
+
end
|
62
|
+
|
63
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock02A
|
64
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock02
|
65
|
+
end
|
66
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock02B
|
67
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock02A
|
68
|
+
end
|
69
|
+
|
70
|
+
ccv = CascadingConfiguration::Variable
|
71
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock02
|
72
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock02A
|
73
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock02B
|
74
|
+
configuration_name = :some_configuration
|
75
|
+
|
76
|
+
# Without super or sub composites
|
77
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
78
|
+
cascading_composite_hash.store( :some_setting, :some_value )
|
79
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
80
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
81
|
+
cascading_composite_hash.store( :other_setting, :some_value )
|
82
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
|
83
|
+
:other_setting => :some_value }
|
84
|
+
cascading_composite_hash.should == { :some_setting => :some_value,
|
85
|
+
:other_setting => :some_value }
|
86
|
+
|
87
|
+
# Super with a sub composite
|
88
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
89
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
90
|
+
sub_cascading_composite_hash.should == { :some_setting => :some_value,
|
91
|
+
:other_setting => :some_value }
|
92
|
+
sub_cascading_composite_hash.store( :yet_another_setting, :some_value )
|
93
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
94
|
+
sub_cascading_composite_hash.should == { :some_setting => :some_value,
|
95
|
+
:other_setting => :some_value,
|
96
|
+
:yet_another_setting => :some_value }
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
############
|
101
|
+
# delete #
|
102
|
+
############
|
103
|
+
|
104
|
+
it 'can exclude elements' do
|
105
|
+
|
106
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock03
|
107
|
+
include CascadingConfiguration::Variable
|
108
|
+
end
|
109
|
+
|
110
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock03A
|
111
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock03
|
112
|
+
end
|
113
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock03B
|
114
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock03A
|
115
|
+
end
|
116
|
+
|
117
|
+
ccv = CascadingConfiguration::Variable
|
118
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock03
|
119
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock03A
|
120
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock03B
|
121
|
+
configuration_name = :some_configuration
|
122
|
+
|
123
|
+
# Without super or sub composites
|
124
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
125
|
+
cascading_composite_hash.store( :some_setting, :some_value )
|
126
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
127
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
128
|
+
cascading_composite_hash.store( :other_setting, :some_value )
|
129
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
|
130
|
+
:other_setting => :some_value }
|
131
|
+
cascading_composite_hash.should == { :some_setting => :some_value,
|
132
|
+
:other_setting => :some_value }
|
133
|
+
cascading_composite_hash.delete( :some_setting )
|
134
|
+
cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
|
135
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
136
|
+
|
137
|
+
# Super with a sub composite
|
138
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
139
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
140
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value }
|
141
|
+
sub_cascading_composite_hash.store( :yet_another_setting, :some_value )
|
142
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
143
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value,
|
144
|
+
:yet_another_setting => :some_value }
|
145
|
+
sub_cascading_composite_hash.delete( :other_setting )
|
146
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
147
|
+
sub_cascading_composite_hash.should == { :yet_another_setting => :some_value }
|
148
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
############
|
153
|
+
# merge! #
|
154
|
+
############
|
155
|
+
|
156
|
+
it 'can merge from another hash' do
|
157
|
+
|
158
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock04
|
159
|
+
include CascadingConfiguration::Variable
|
160
|
+
end
|
161
|
+
|
162
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock04A
|
163
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock04
|
164
|
+
end
|
165
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock04B
|
166
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock04A
|
167
|
+
end
|
168
|
+
|
169
|
+
ccv = CascadingConfiguration::Variable
|
170
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock04
|
171
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock04A
|
172
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock04B
|
173
|
+
configuration_name = :some_configuration
|
174
|
+
|
175
|
+
# Without super or sub composites
|
176
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
177
|
+
cascading_composite_hash.merge!( :some_setting => :some_value )
|
178
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
179
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
180
|
+
cascading_composite_hash.merge!( :other_setting => :some_value )
|
181
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
|
182
|
+
:other_setting => :some_value }
|
183
|
+
cascading_composite_hash.should == { :some_setting => :some_value,
|
184
|
+
:other_setting => :some_value }
|
185
|
+
|
186
|
+
# Super with a sub composite
|
187
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
188
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
189
|
+
sub_cascading_composite_hash.should == { :some_setting => :some_value,
|
190
|
+
:other_setting => :some_value }
|
191
|
+
sub_cascading_composite_hash.merge!( :yet_another_setting => :some_value )
|
192
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
193
|
+
sub_cascading_composite_hash.should == { :some_setting => :some_value,
|
194
|
+
:other_setting => :some_value,
|
195
|
+
:yet_another_setting => :some_value }
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
#############
|
200
|
+
# replace #
|
201
|
+
#############
|
202
|
+
|
203
|
+
it 'can replace existing elements with others' do
|
204
|
+
|
205
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock05
|
206
|
+
include CascadingConfiguration::Variable
|
207
|
+
end
|
208
|
+
|
209
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock05A
|
210
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock05
|
211
|
+
end
|
212
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock05B
|
213
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock05A
|
214
|
+
end
|
215
|
+
|
216
|
+
ccv = CascadingConfiguration::Variable
|
217
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock05
|
218
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock05A
|
219
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock05B
|
220
|
+
configuration_name = :some_configuration
|
221
|
+
|
222
|
+
# Without super or sub composites
|
223
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
224
|
+
cascading_composite_hash.replace( :some_setting => :some_value )
|
225
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
226
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
227
|
+
cascading_composite_hash.replace( :other_setting => :some_value )
|
228
|
+
cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
|
229
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
230
|
+
|
231
|
+
# Super with a sub composite
|
232
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
233
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
234
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value }
|
235
|
+
sub_cascading_composite_hash.replace( :yet_another_setting => :some_value )
|
236
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
237
|
+
sub_cascading_composite_hash.should == { :yet_another_setting => :some_value }
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
###########
|
242
|
+
# shift #
|
243
|
+
###########
|
244
|
+
|
245
|
+
it 'can shift the first element' do
|
246
|
+
|
247
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock06
|
248
|
+
include CascadingConfiguration::Variable
|
249
|
+
end
|
250
|
+
|
251
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock06A
|
252
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock06
|
253
|
+
end
|
254
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock06B
|
255
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock06A
|
256
|
+
end
|
257
|
+
|
258
|
+
ccv = CascadingConfiguration::Variable
|
259
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock06
|
260
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock06A
|
261
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock06B
|
262
|
+
configuration_name = :some_configuration
|
263
|
+
|
264
|
+
# Without super or sub composites
|
265
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
266
|
+
cascading_composite_hash.store( :some_setting, :some_value )
|
267
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
268
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
269
|
+
cascading_composite_hash.store( :other_setting, :some_value )
|
270
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
|
271
|
+
:other_setting => :some_value }
|
272
|
+
cascading_composite_hash.should == { :some_setting => :some_value,
|
273
|
+
:other_setting => :some_value }
|
274
|
+
cascading_composite_hash.shift
|
275
|
+
cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
|
276
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
277
|
+
|
278
|
+
# Super with a sub composite
|
279
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
280
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
281
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value }
|
282
|
+
sub_cascading_composite_hash.store( :yet_another_setting, :some_value )
|
283
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
284
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value,
|
285
|
+
:yet_another_setting => :some_value }
|
286
|
+
sub_cascading_composite_hash.shift
|
287
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
288
|
+
sub_cascading_composite_hash.should == { :yet_another_setting => :some_value }
|
289
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
###########
|
294
|
+
# clear #
|
295
|
+
###########
|
296
|
+
|
297
|
+
it 'can clear, causing present elements to be excluded' do
|
298
|
+
|
299
|
+
module CascadingConfiguration::Hash::CompositingHash::CCHMock07
|
300
|
+
include CascadingConfiguration::Variable
|
301
|
+
end
|
302
|
+
|
303
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock07A
|
304
|
+
include CascadingConfiguration::Hash::CompositingHash::CCHMock07
|
305
|
+
end
|
306
|
+
module CascadingConfiguration::Hash::CompositingHash::CIMock07B
|
307
|
+
include CascadingConfiguration::Hash::CompositingHash::CIMock07A
|
308
|
+
end
|
309
|
+
|
310
|
+
ccv = CascadingConfiguration::Variable
|
311
|
+
ccm_hash = CascadingConfiguration::Hash::CompositingHash::CCHMock07
|
312
|
+
configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock07A
|
313
|
+
sub_configuration_instance = CascadingConfiguration::Hash::CompositingHash::CIMock07B
|
314
|
+
configuration_name = :some_configuration
|
315
|
+
|
316
|
+
# Without super or sub composites
|
317
|
+
cascading_composite_hash = ::CascadingConfiguration::Hash::CompositingHash.new( configuration_instance, configuration_name )
|
318
|
+
cascading_composite_hash.store( :some_setting, :some_value )
|
319
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
|
320
|
+
cascading_composite_hash.should == { :some_setting => :some_value }
|
321
|
+
cascading_composite_hash.store( :other_setting, :some_value )
|
322
|
+
cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
|
323
|
+
:other_setting => :some_value }
|
324
|
+
cascading_composite_hash.should == { :some_setting => :some_value,
|
325
|
+
:other_setting => :some_value }
|
326
|
+
cascading_composite_hash.clear
|
327
|
+
cascading_composite_hash.local_cascading_hash.should == { }
|
328
|
+
cascading_composite_hash.should == { }
|
329
|
+
cascading_composite_hash.store( :other_setting, :some_value )
|
330
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
331
|
+
|
332
|
+
# Super with a sub composite
|
333
|
+
sub_cascading_composite_hash = CascadingConfiguration::Hash::CompositingHash.new( sub_configuration_instance, configuration_name )
|
334
|
+
sub_cascading_composite_hash.local_cascading_hash.should == {}
|
335
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value }
|
336
|
+
sub_cascading_composite_hash.store( :yet_another_setting, :some_value )
|
337
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
|
338
|
+
sub_cascading_composite_hash.should == { :other_setting => :some_value,
|
339
|
+
:yet_another_setting => :some_value }
|
340
|
+
sub_cascading_composite_hash.clear
|
341
|
+
sub_cascading_composite_hash.local_cascading_hash.should == { }
|
342
|
+
sub_cascading_composite_hash.should == { }
|
343
|
+
cascading_composite_hash.should == { :other_setting => :some_value }
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cascading-configuration-hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 4
|
8
|
-
- 1
|
9
|
-
version: 1.4.1
|
4
|
+
prerelease:
|
5
|
+
version: 1.5.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Asher
|
@@ -14,8 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
13
|
+
date: 2012-01-16 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: module-cluster
|
@@ -25,8 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
23
|
version: "0"
|
31
24
|
type: :runtime
|
32
25
|
version_requirements: *id001
|
@@ -38,8 +31,6 @@ dependencies:
|
|
38
31
|
requirements:
|
39
32
|
- - ">="
|
40
33
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
34
|
version: "0"
|
44
35
|
type: :runtime
|
45
36
|
version_requirements: *id002
|
@@ -52,23 +43,18 @@ extensions: []
|
|
52
43
|
extra_rdoc_files: []
|
53
44
|
|
54
45
|
files:
|
55
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/
|
56
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/
|
57
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/
|
58
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/
|
59
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/Hash/AccessorDefinitionMethods.rb
|
60
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/Hash/Interface/Instance.rb
|
46
|
+
- lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/CompositingHash/LocalConfigurationHash.rb
|
47
|
+
- lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/CompositingHash.rb
|
48
|
+
- lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/Interface/GettersSetters.rb
|
49
|
+
- lib/cascading-configuration-hash/_private_/CascadingConfiguration/Hash/ModuleSupportMethods.rb
|
61
50
|
- lib/cascading-configuration-hash/CascadingConfiguration/Hash/Interface.rb
|
62
51
|
- lib/cascading-configuration-hash/CascadingConfiguration/Hash.rb
|
63
|
-
- lib/cascading-configuration-hash/CascadingConfiguration/LocalConfigurationHash.rb
|
64
52
|
- lib/cascading-configuration-hash.rb
|
65
|
-
- spec/CascadingConfiguration/
|
66
|
-
- spec/CascadingConfiguration/Hash/
|
53
|
+
- spec/_private_/CascadingConfiguration/Hash/CompositingHash/LocalConfigurationHash_spec.rb
|
54
|
+
- spec/_private_/CascadingConfiguration/Hash/CompositingHash_spec.rb
|
67
55
|
- spec/CascadingConfiguration/Hash_spec.rb
|
68
|
-
- spec/CascadingConfiguration/LocalConfigurationHash_spec.rb
|
69
56
|
- README.md
|
70
57
|
- README.rdoc
|
71
|
-
has_rdoc: true
|
72
58
|
homepage: http://rubygems.org/gems/cascading-configuration-hash
|
73
59
|
licenses: []
|
74
60
|
|
@@ -82,21 +68,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
68
|
requirements:
|
83
69
|
- - ">="
|
84
70
|
- !ruby/object:Gem::Version
|
85
|
-
segments:
|
86
|
-
- 0
|
87
71
|
version: "0"
|
88
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
73
|
none: false
|
90
74
|
requirements:
|
91
75
|
- - ">="
|
92
76
|
- !ruby/object:Gem::Version
|
93
|
-
segments:
|
94
|
-
- 0
|
95
77
|
version: "0"
|
96
78
|
requirements: []
|
97
79
|
|
98
80
|
rubyforge_project: cascading-configuration-hash
|
99
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.8.10
|
100
82
|
signing_key:
|
101
83
|
specification_version: 3
|
102
84
|
summary: Support package for cascading-configuration.
|
@@ -1,31 +0,0 @@
|
|
1
|
-
|
2
|
-
module CascadingConfiguration::CompositingHash::Instance
|
3
|
-
|
4
|
-
extend ModuleCluster
|
5
|
-
|
6
|
-
extend CascadingConfiguration::InternalModuleStub
|
7
|
-
|
8
|
-
include_also_extends( self )
|
9
|
-
|
10
|
-
################################################
|
11
|
-
# composite_hash_for_cascading_configuration #
|
12
|
-
################################################
|
13
|
-
|
14
|
-
def composite_hash_for_cascading_configuration( cascading_name )
|
15
|
-
|
16
|
-
composite_hash = nil
|
17
|
-
|
18
|
-
klass = ( is_a?( Module ) ? self : self.class )
|
19
|
-
self_instance = self
|
20
|
-
accessor_module_support.instance_eval do
|
21
|
-
unless composite_hash = ( ( @composite_hashes ||= Hash.new )[ cascading_name ] ||= Hash.new )[ self_instance ]
|
22
|
-
composite_hash = ::CascadingConfiguration::CompositingHash.new( cascading_name, self_instance )
|
23
|
-
@composite_hashes[ cascading_name ][ self_instance ] = composite_hash
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
return composite_hash
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
|
2
|
-
class CascadingConfiguration::CompositingHash < Hash
|
3
|
-
|
4
|
-
attr_accessor :working_instance, :local_cascading_hash
|
5
|
-
|
6
|
-
################
|
7
|
-
# initialize #
|
8
|
-
################
|
9
|
-
|
10
|
-
def initialize( cascading_name, working_instance )
|
11
|
-
@cascading_name = cascading_name
|
12
|
-
@working_class = ( working_instance.is_a?( Module ) ? working_instance : working_instance.class )
|
13
|
-
@working_instance = working_instance
|
14
|
-
# if first ancestor can have a composite array, register self with it in case it gets updated in the future
|
15
|
-
if ( first_ancestor = @working_instance.first_ancestor ).respond_to?( :composite_hash_for_cascading_configuration )
|
16
|
-
@parent_composite_hash = first_ancestor.composite_hash_for_cascading_configuration( @cascading_name )
|
17
|
-
@parent_composite_hash.register_child_composite_hash( self )
|
18
|
-
end
|
19
|
-
# get local cascading array (not included in parent composite)
|
20
|
-
@local_cascading_hash = ::CascadingConfiguration::LocalConfigurationHash.new
|
21
|
-
# we may later have our own child composites
|
22
|
-
@child_composite_hashes = ::Array.new
|
23
|
-
# initialize self status for parent and local
|
24
|
-
update_self_as_cascading_composite
|
25
|
-
end
|
26
|
-
|
27
|
-
###################################
|
28
|
-
# register_child_composite_hash #
|
29
|
-
###################################
|
30
|
-
|
31
|
-
def register_child_composite_hash( child_composite_hash )
|
32
|
-
@child_composite_hashes.push( child_composite_hash )
|
33
|
-
return self
|
34
|
-
end
|
35
|
-
|
36
|
-
#####################################
|
37
|
-
# unregister_child_composite_hash #
|
38
|
-
#####################################
|
39
|
-
|
40
|
-
def unregister_child_composite_hash( child_composite_hash )
|
41
|
-
@child_composite_hashes.delete( child_composite_hash )
|
42
|
-
return self
|
43
|
-
end
|
44
|
-
|
45
|
-
#########
|
46
|
-
# []= #
|
47
|
-
#########
|
48
|
-
|
49
|
-
def []=( key, value )
|
50
|
-
@local_cascading_hash[ key ] = value
|
51
|
-
update_adding_composite_elements( key => value )
|
52
|
-
end
|
53
|
-
alias_method :store, :[]=
|
54
|
-
|
55
|
-
############
|
56
|
-
# delete #
|
57
|
-
############
|
58
|
-
|
59
|
-
alias_method :super_delete, :delete
|
60
|
-
def delete( key )
|
61
|
-
value = self[ key ]
|
62
|
-
@local_cascading_hash.delete( key )
|
63
|
-
update_removing_composite_elements( key )
|
64
|
-
return value
|
65
|
-
end
|
66
|
-
|
67
|
-
############
|
68
|
-
# merge! #
|
69
|
-
############
|
70
|
-
|
71
|
-
alias_method :super_merge!, :merge!
|
72
|
-
def merge!( other_hash )
|
73
|
-
@local_cascading_hash.merge!( other_hash )
|
74
|
-
update_adding_composite_elements( other_hash )
|
75
|
-
return self
|
76
|
-
end
|
77
|
-
|
78
|
-
#############
|
79
|
-
# replace #
|
80
|
-
#############
|
81
|
-
|
82
|
-
alias_method :super_replace, :replace
|
83
|
-
def replace( other_hash )
|
84
|
-
# clear current values
|
85
|
-
clear
|
86
|
-
# merge replacement settings
|
87
|
-
merge!( other_hash )
|
88
|
-
update_self_as_cascading_composite
|
89
|
-
return self
|
90
|
-
end
|
91
|
-
|
92
|
-
###########
|
93
|
-
# shift #
|
94
|
-
###########
|
95
|
-
|
96
|
-
def shift
|
97
|
-
element = super
|
98
|
-
key = element[ 0 ]
|
99
|
-
@local_cascading_hash.delete( key )
|
100
|
-
update_removing_composite_elements( key )
|
101
|
-
return element
|
102
|
-
end
|
103
|
-
|
104
|
-
###########
|
105
|
-
# clear #
|
106
|
-
###########
|
107
|
-
|
108
|
-
alias_method :super_clear, :clear
|
109
|
-
def clear
|
110
|
-
# add all existing values to exclude array
|
111
|
-
keys.each do |this_key|
|
112
|
-
delete( this_key )
|
113
|
-
end
|
114
|
-
update_removing_composite_elements( *self.keys )
|
115
|
-
return self
|
116
|
-
end
|
117
|
-
|
118
|
-
#############
|
119
|
-
# freeze! #
|
120
|
-
#############
|
121
|
-
|
122
|
-
# freezes configuration and prevents ancestors from changing this configuration in the future
|
123
|
-
def freeze!
|
124
|
-
|
125
|
-
# move current configuration into local configuration
|
126
|
-
@local_cascading_hash.replace( self )
|
127
|
-
|
128
|
-
# unregister with parent composite so we don't get future updates from it
|
129
|
-
@parent_composite_hash.unregister_child_composite_hash( self ) if @parent_composite_hash
|
130
|
-
|
131
|
-
return self
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|