cascading-configuration-array 1.6.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cascading-configuration-array/CascadingConfiguration/Array/Interface.rb +16 -16
- data/lib/cascading-configuration-array/CascadingConfiguration/Array.rb +2 -2
- data/lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/CompositingArray.rb +700 -124
- data/lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/Interface/GettersSetters.rb +59 -37
- data/lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/ModuleSupportMethods.rb +18 -15
- data/lib/cascading-configuration-array.rb +5 -5
- data/spec/CascadingConfiguration/Array_spec.rb +22 -18
- data/spec/_private_/CascadingConfiguration/Array/CompositingArray_spec.rb +903 -474
- metadata +6 -8
- data/lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/CompositingArray/LocalConfigurationArray.rb +0 -192
- data/spec/_private_/CascadingConfiguration/Array/CompositingArray/LocalConfigurationArray_spec.rb +0 -155
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::Array::Interface::GettersSetters
|
2
|
+
module ::CascadingConfiguration::Array::Interface::GettersSetters
|
3
3
|
|
4
4
|
###################################
|
5
5
|
# define_cascading_array_setter #
|
@@ -11,14 +11,19 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
11
11
|
|
12
12
|
array_setter_proc = Proc.new do |array|
|
13
13
|
|
14
|
-
return CascadingConfiguration::Array.
|
15
|
-
|
16
|
-
|
14
|
+
return ::CascadingConfiguration::Array.set_composite_array( self,
|
15
|
+
configuration_name,
|
16
|
+
array )
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
::CascadingConfiguration::Variable.define_module_method( self,
|
21
|
+
configuration_setter_name,
|
22
|
+
& array_setter_proc )
|
23
|
+
::CascadingConfiguration::Variable.
|
24
|
+
define_instance_method_if_support_exists( self,
|
25
|
+
configuration_setter_name,
|
26
|
+
& array_setter_proc )
|
22
27
|
|
23
28
|
end
|
24
29
|
|
@@ -32,13 +37,18 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
32
37
|
|
33
38
|
array_getter_proc = Proc.new do
|
34
39
|
|
35
|
-
return CascadingConfiguration::Array.
|
36
|
-
|
40
|
+
return ::CascadingConfiguration::Array.composite_array( self,
|
41
|
+
configuration_name )
|
37
42
|
|
38
43
|
end
|
39
44
|
|
40
|
-
|
41
|
-
|
45
|
+
::CascadingConfiguration::Variable.define_module_method( self,
|
46
|
+
configuration_getter_name,
|
47
|
+
& array_getter_proc )
|
48
|
+
::CascadingConfiguration::Variable.
|
49
|
+
define_instance_method_if_support_exists( self,
|
50
|
+
configuration_getter_name,
|
51
|
+
& array_getter_proc )
|
42
52
|
|
43
53
|
end
|
44
54
|
|
@@ -50,11 +60,12 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
50
60
|
|
51
61
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
52
62
|
|
53
|
-
::CascadingConfiguration::Variable.define_module_method( self,
|
63
|
+
::CascadingConfiguration::Variable.define_module_method( self,
|
64
|
+
configuration_setter_name ) do |array|
|
54
65
|
|
55
|
-
return CascadingConfiguration::Array.
|
56
|
-
|
57
|
-
|
66
|
+
return ::CascadingConfiguration::Array.set_composite_array( self,
|
67
|
+
configuration_name,
|
68
|
+
array )
|
58
69
|
|
59
70
|
end
|
60
71
|
|
@@ -70,8 +81,8 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
70
81
|
|
71
82
|
::CascadingConfiguration::Variable.define_module_method( self, configuration_getter_name ) do
|
72
83
|
|
73
|
-
return CascadingConfiguration::Array.
|
74
|
-
|
84
|
+
return ::CascadingConfiguration::Array.composite_array( self,
|
85
|
+
configuration_name )
|
75
86
|
|
76
87
|
end
|
77
88
|
|
@@ -87,14 +98,19 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
87
98
|
|
88
99
|
local_setter_proc = Proc.new do |array|
|
89
100
|
|
90
|
-
return CascadingConfiguration::Array.
|
91
|
-
|
92
|
-
|
101
|
+
return ::CascadingConfiguration::Array.set_composite_array( self,
|
102
|
+
configuration_name,
|
103
|
+
array )
|
93
104
|
|
94
105
|
end
|
95
106
|
|
96
|
-
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
97
|
-
|
107
|
+
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
108
|
+
configuration_setter_name,
|
109
|
+
& local_setter_proc )
|
110
|
+
::CascadingConfiguration::Variable.
|
111
|
+
define_instance_method_if_support_exists( self,
|
112
|
+
configuration_setter_name,
|
113
|
+
& local_setter_proc )
|
98
114
|
|
99
115
|
end
|
100
116
|
|
@@ -108,13 +124,18 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
108
124
|
|
109
125
|
local_getter_proc = Proc.new do
|
110
126
|
|
111
|
-
return CascadingConfiguration::Array.
|
112
|
-
|
127
|
+
return ::CascadingConfiguration::Array.composite_array( self,
|
128
|
+
configuration_name )
|
113
129
|
|
114
130
|
end
|
115
131
|
|
116
|
-
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
117
|
-
|
132
|
+
::CascadingConfiguration::Variable.define_local_instance_method( self,
|
133
|
+
configuration_getter_name,
|
134
|
+
& local_getter_proc )
|
135
|
+
::CascadingConfiguration::Variable.
|
136
|
+
define_instance_method_if_support_exists( self,
|
137
|
+
configuration_getter_name,
|
138
|
+
& local_getter_proc )
|
118
139
|
|
119
140
|
end
|
120
141
|
|
@@ -126,11 +147,12 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
126
147
|
|
127
148
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
128
149
|
|
129
|
-
::CascadingConfiguration::Variable.
|
150
|
+
::CascadingConfiguration::Variable.
|
151
|
+
define_instance_method( self, configuration_setter_name ) do |array|
|
130
152
|
|
131
|
-
return CascadingConfiguration::Array.
|
132
|
-
|
133
|
-
|
153
|
+
return ::CascadingConfiguration::Array.set_composite_array( self,
|
154
|
+
configuration_name,
|
155
|
+
array )
|
134
156
|
|
135
157
|
end
|
136
158
|
|
@@ -146,8 +168,8 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
146
168
|
|
147
169
|
::CascadingConfiguration::Variable.define_instance_method( self, configuration_getter_name ) do
|
148
170
|
|
149
|
-
return CascadingConfiguration::Array.
|
150
|
-
|
171
|
+
return ::CascadingConfiguration::Array.composite_array( self,
|
172
|
+
configuration_name )
|
151
173
|
|
152
174
|
end
|
153
175
|
|
@@ -161,11 +183,12 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
161
183
|
|
162
184
|
configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
|
163
185
|
|
164
|
-
::CascadingConfiguration::Variable.
|
186
|
+
::CascadingConfiguration::Variable.
|
187
|
+
define_local_instance_method( self, configuration_setter_name ) do |array|
|
165
188
|
|
166
|
-
return CascadingConfiguration::Array.
|
167
|
-
|
168
|
-
|
189
|
+
return ::CascadingConfiguration::Array.set_composite_array( self,
|
190
|
+
configuration_name,
|
191
|
+
array )
|
169
192
|
|
170
193
|
end
|
171
194
|
|
@@ -181,8 +204,7 @@ module CascadingConfiguration::Array::Interface::GettersSetters
|
|
181
204
|
|
182
205
|
::CascadingConfiguration::Variable.define_local_instance_method( self, configuration_getter_name ) do
|
183
206
|
|
184
|
-
return CascadingConfiguration::Array.
|
185
|
-
configuration_name )
|
207
|
+
return ::CascadingConfiguration::Array.composite_array( self, configuration_name )
|
186
208
|
|
187
209
|
end
|
188
210
|
|
@@ -1,31 +1,34 @@
|
|
1
1
|
|
2
|
-
module CascadingConfiguration::Array::ModuleSupportMethods
|
2
|
+
module ::CascadingConfiguration::Array::ModuleSupportMethods
|
3
3
|
|
4
|
-
|
5
|
-
#
|
6
|
-
|
4
|
+
#####################
|
5
|
+
# composite_array #
|
6
|
+
#####################
|
7
7
|
|
8
|
-
def
|
8
|
+
def composite_array( configuration_instance, configuration_name )
|
9
9
|
|
10
10
|
composite_array = nil
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
if ::CascadingConfiguration::Variable.has_configuration_variable?( configuration_instance,
|
13
|
+
configuration_name )
|
14
|
+
composite_array = ::CascadingConfiguration::Variable.
|
15
|
+
get_configuration_variable( configuration_instance, configuration_name )
|
16
|
+
else
|
17
|
+
composite_array = ::CascadingConfiguration::Array::CompositingArray.
|
18
|
+
new( configuration_instance, configuration_name )
|
19
|
+
end
|
17
20
|
|
18
21
|
return composite_array
|
19
22
|
|
20
23
|
end
|
21
24
|
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
+
#########################
|
26
|
+
# set_composite_array #
|
27
|
+
#########################
|
25
28
|
|
26
|
-
def
|
29
|
+
def set_composite_array( configuration_instance, configuration_name, array )
|
27
30
|
|
28
|
-
composite_array =
|
31
|
+
composite_array = composite_array( configuration_instance, configuration_name )
|
29
32
|
|
30
33
|
# we want the array to supplant existing config
|
31
34
|
# clear the array (excludes everything explicitly)
|
@@ -1,12 +1,13 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
2
|
+
if $__cascading_configuration__spec__development
|
3
|
+
require_relative '../../variable/lib/cascading-configuration-variable.rb'
|
4
|
+
else
|
5
|
+
require 'cascading-configuration-variable'
|
6
|
+
end
|
4
7
|
|
5
8
|
module CascadingConfiguration
|
6
9
|
module Array
|
7
10
|
class CompositingArray < ::Array
|
8
|
-
class LocalConfigurationArray < ::Array
|
9
|
-
end
|
10
11
|
end
|
11
12
|
module ModuleSupportMethods
|
12
13
|
end
|
@@ -17,7 +18,6 @@ module CascadingConfiguration
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
require_relative 'cascading-configuration-array/_private_/CascadingConfiguration/Array/CompositingArray/LocalConfigurationArray.rb'
|
21
21
|
require_relative 'cascading-configuration-array/_private_/CascadingConfiguration/Array/CompositingArray.rb'
|
22
22
|
require_relative 'cascading-configuration-array/_private_/CascadingConfiguration/Array/Interface/GettersSetters.rb'
|
23
23
|
require_relative 'cascading-configuration-array/_private_/CascadingConfiguration/Array/ModuleSupportMethods.rb'
|
@@ -1,5 +1,9 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
if $__cascading_configuration__spec__development
|
3
|
+
require_relative '../../lib/cascading-configuration-array.rb'
|
4
|
+
else
|
5
|
+
require 'cascading-configuration-array'
|
6
|
+
end
|
3
7
|
|
4
8
|
describe CascadingConfiguration::Array do
|
5
9
|
|
@@ -152,29 +156,29 @@ describe CascadingConfiguration::Array do
|
|
152
156
|
object_instance_two.instance_variables.empty?.should == true
|
153
157
|
class CascadingConfiguration::Array::ConfigurationMockClassSub2 < CascadingConfiguration::Array::ConfigurationMockClassSub1
|
154
158
|
configuration_setting.should == [ :another_configuration, :some_other_configuration ]
|
155
|
-
configuration_setting.push( :yet_another_configuration )
|
156
|
-
configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
159
|
+
#configuration_setting.push( :yet_another_configuration )
|
160
|
+
#configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
|
157
161
|
instance_variables.empty?.should == true
|
158
162
|
end
|
159
163
|
|
160
164
|
# change ancestor setting
|
161
165
|
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
162
166
|
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
163
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :
|
164
|
-
object_instance_one.configuration_setting.should == [ :
|
165
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :
|
166
|
-
object_instance_two.configuration_setting.should == [ :
|
167
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
168
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
169
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
170
|
+
object_instance_two.configuration_setting.should == [ :some_other_configuration, :a_yet_unused_configuration ]
|
167
171
|
|
168
172
|
# freeze ancestor setting
|
169
173
|
object_instance_one.configuration_setting.freeze!
|
170
|
-
object_instance_one.configuration_setting.should == [ :
|
174
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
171
175
|
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.freeze!
|
172
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :
|
176
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
173
177
|
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
174
|
-
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :
|
175
|
-
object_instance_one.configuration_setting.should == [ :
|
176
|
-
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :
|
177
|
-
object_instance_two.configuration_setting.should == [ :
|
178
|
+
CascadingConfiguration::Array::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration, :non_cascading_configuration ]
|
179
|
+
object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
180
|
+
CascadingConfiguration::Array::ConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
181
|
+
object_instance_two.configuration_setting.should == [ :some_other_configuration, :a_yet_unused_configuration ]
|
178
182
|
|
179
183
|
end
|
180
184
|
|
@@ -334,15 +338,15 @@ describe CascadingConfiguration::Array do
|
|
334
338
|
# change ancestor setting
|
335
339
|
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
|
336
340
|
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
|
337
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :
|
338
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :
|
341
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
342
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
339
343
|
|
340
344
|
# freeze ancestor setting
|
341
345
|
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.freeze!
|
342
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :
|
346
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
343
347
|
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
|
344
|
-
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :
|
345
|
-
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :
|
348
|
+
CascadingConfiguration::Array::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration, :a_yet_unused_configuration, :non_cascading_configuration ]
|
349
|
+
CascadingConfiguration::Array::ClassConfigurationMockClassSub1.configuration_setting.should == [ :another_configuration, :some_other_configuration, :a_yet_unused_configuration ]
|
346
350
|
|
347
351
|
end
|
348
352
|
|