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
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cascading-configuration-array
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: module-cluster
|
16
|
-
requirement: &
|
16
|
+
requirement: &70312989933080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70312989933080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cascading-configuration-variable
|
27
|
-
requirement: &
|
27
|
+
requirement: &70312989932640 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,21 +32,19 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70312989932640
|
36
36
|
description: Provides :attr_configuration_array.
|
37
37
|
email: asher@ridiculouspower.com
|
38
38
|
executables: []
|
39
39
|
extensions: []
|
40
40
|
extra_rdoc_files: []
|
41
41
|
files:
|
42
|
-
- lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/CompositingArray/LocalConfigurationArray.rb
|
43
42
|
- lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/CompositingArray.rb
|
44
43
|
- lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/Interface/GettersSetters.rb
|
45
44
|
- lib/cascading-configuration-array/_private_/CascadingConfiguration/Array/ModuleSupportMethods.rb
|
46
45
|
- lib/cascading-configuration-array/CascadingConfiguration/Array/Interface.rb
|
47
46
|
- lib/cascading-configuration-array/CascadingConfiguration/Array.rb
|
48
47
|
- lib/cascading-configuration-array.rb
|
49
|
-
- spec/_private_/CascadingConfiguration/Array/CompositingArray/LocalConfigurationArray_spec.rb
|
50
48
|
- spec/_private_/CascadingConfiguration/Array/CompositingArray_spec.rb
|
51
49
|
- spec/CascadingConfiguration/Array_spec.rb
|
52
50
|
- README.md
|
@@ -1,192 +0,0 @@
|
|
1
|
-
|
2
|
-
class CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray < Array
|
3
|
-
|
4
|
-
# A LocalConfigurationArray is a single layer of a CompositingArray.
|
5
|
-
# The LocalConfigurationArray holds the layer's settings and exclude values.
|
6
|
-
# CompositingArray uses LocalConfigurationArray to cascade.
|
7
|
-
|
8
|
-
attr_accessor :exclude_array
|
9
|
-
|
10
|
-
################
|
11
|
-
# initialize #
|
12
|
-
################
|
13
|
-
|
14
|
-
def initialize()
|
15
|
-
@exclude_array = [ ]
|
16
|
-
end
|
17
|
-
|
18
|
-
#########
|
19
|
-
# []= #
|
20
|
-
#########
|
21
|
-
|
22
|
-
def []=( index, element )
|
23
|
-
# we sort internally, so index is irrelevant
|
24
|
-
# no reason to differentiate from push
|
25
|
-
push( element )
|
26
|
-
end
|
27
|
-
|
28
|
-
########
|
29
|
-
# << #
|
30
|
-
########
|
31
|
-
|
32
|
-
def <<( *elements )
|
33
|
-
# no reason to differentiate from push
|
34
|
-
push( *elements )
|
35
|
-
end
|
36
|
-
|
37
|
-
#######
|
38
|
-
# + #
|
39
|
-
#######
|
40
|
-
|
41
|
-
def +( *element_arrays )
|
42
|
-
element_arrays.each do |this_element_array|
|
43
|
-
push( *this_element_array )
|
44
|
-
end
|
45
|
-
return self
|
46
|
-
end
|
47
|
-
|
48
|
-
##########
|
49
|
-
# push #
|
50
|
-
##########
|
51
|
-
|
52
|
-
def push( *elements )
|
53
|
-
|
54
|
-
# add elements to configuration array
|
55
|
-
super
|
56
|
-
|
57
|
-
# sort and uniq self
|
58
|
-
sort!.uniq!
|
59
|
-
|
60
|
-
# make sure we don't still have any elements noted as excluded at this level
|
61
|
-
remove_from_exclude_array( *elements )
|
62
|
-
|
63
|
-
return self
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
############
|
68
|
-
# concat #
|
69
|
-
############
|
70
|
-
|
71
|
-
def concat( *arrays )
|
72
|
-
|
73
|
-
arrays.each do |this_array|
|
74
|
-
push( *this_array )
|
75
|
-
end
|
76
|
-
|
77
|
-
return self
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
#######
|
82
|
-
# - #
|
83
|
-
#######
|
84
|
-
|
85
|
-
def -( *arrays )
|
86
|
-
|
87
|
-
arrays.each do |this_array|
|
88
|
-
delete( *this_array )
|
89
|
-
end
|
90
|
-
|
91
|
-
return self
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
############
|
96
|
-
# delete #
|
97
|
-
############
|
98
|
-
|
99
|
-
def delete( *elements )
|
100
|
-
|
101
|
-
elements.each do |this_element|
|
102
|
-
super( this_element )
|
103
|
-
end
|
104
|
-
# add subtracted elements to exclude array
|
105
|
-
add_to_exclude_array( *elements )
|
106
|
-
|
107
|
-
return self
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
#########
|
112
|
-
# pop #
|
113
|
-
#########
|
114
|
-
|
115
|
-
def pop
|
116
|
-
|
117
|
-
element = super
|
118
|
-
|
119
|
-
# add popped element to exclude array
|
120
|
-
add_to_exclude_array( element )
|
121
|
-
|
122
|
-
return element
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
###########
|
127
|
-
# shift #
|
128
|
-
###########
|
129
|
-
|
130
|
-
def shift
|
131
|
-
|
132
|
-
element = super
|
133
|
-
|
134
|
-
# add shifted element to exclude array
|
135
|
-
add_to_exclude_array( element )
|
136
|
-
|
137
|
-
return element
|
138
|
-
|
139
|
-
end
|
140
|
-
|
141
|
-
############
|
142
|
-
# slice! #
|
143
|
-
############
|
144
|
-
|
145
|
-
def slice!( *args )
|
146
|
-
|
147
|
-
elements = super
|
148
|
-
|
149
|
-
# add sliced elements to exclude array
|
150
|
-
delete( *elements )
|
151
|
-
|
152
|
-
return elements
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
###########
|
157
|
-
# clear #
|
158
|
-
###########
|
159
|
-
|
160
|
-
def clear
|
161
|
-
|
162
|
-
# add all existing values to exclude array
|
163
|
-
delete( *self )
|
164
|
-
|
165
|
-
# clear existing values
|
166
|
-
super
|
167
|
-
|
168
|
-
end
|
169
|
-
|
170
|
-
###########################################################################################################
|
171
|
-
private ###############################################################################################
|
172
|
-
###########################################################################################################
|
173
|
-
|
174
|
-
##########################
|
175
|
-
# add_to_exclude_array #
|
176
|
-
##########################
|
177
|
-
|
178
|
-
def add_to_exclude_array( *elements )
|
179
|
-
@exclude_array += elements
|
180
|
-
@exclude_array.sort!.uniq!
|
181
|
-
end
|
182
|
-
|
183
|
-
###############################
|
184
|
-
# remove_from_exclude_array #
|
185
|
-
###############################
|
186
|
-
|
187
|
-
def remove_from_exclude_array( *elements )
|
188
|
-
@exclude_array -= elements
|
189
|
-
@exclude_array.sort!.uniq!
|
190
|
-
end
|
191
|
-
|
192
|
-
end
|
data/spec/_private_/CascadingConfiguration/Array/CompositingArray/LocalConfigurationArray_spec.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../../../lib/cascading-configuration-array.rb'
|
3
|
-
|
4
|
-
describe CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray do
|
5
|
-
|
6
|
-
#########
|
7
|
-
# []= #
|
8
|
-
#########
|
9
|
-
|
10
|
-
it 'can add elements' do
|
11
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
12
|
-
array_instance[0] = :some_setting
|
13
|
-
array_instance.should == [ :some_setting ]
|
14
|
-
array_instance.exclude_array.include?( :some_setting ).should == false
|
15
|
-
array_instance[1] = :other_setting
|
16
|
-
array_instance.should == [ :other_setting, :some_setting ]
|
17
|
-
array_instance.exclude_array.include?( :other_setting ).should == false
|
18
|
-
end
|
19
|
-
|
20
|
-
########
|
21
|
-
# << #
|
22
|
-
########
|
23
|
-
|
24
|
-
it 'can add elements' do
|
25
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
26
|
-
array_instance << :some_setting
|
27
|
-
array_instance.should == [ :some_setting ]
|
28
|
-
array_instance.exclude_array.include?( :some_setting ).should == false
|
29
|
-
array_instance << :other_setting
|
30
|
-
array_instance.should == [ :other_setting, :some_setting ]
|
31
|
-
array_instance.exclude_array.include?( :other_setting ).should == false
|
32
|
-
end
|
33
|
-
|
34
|
-
#######
|
35
|
-
# + #
|
36
|
-
#######
|
37
|
-
|
38
|
-
it 'can add elements' do
|
39
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
40
|
-
array_instance += [ :some_setting ]
|
41
|
-
array_instance.should == [ :some_setting ]
|
42
|
-
array_instance.exclude_array.include?( :some_setting ).should == false
|
43
|
-
array_instance += [ :other_setting ]
|
44
|
-
array_instance.should == [ :other_setting, :some_setting ]
|
45
|
-
array_instance.exclude_array.include?( :other_setting ).should == false
|
46
|
-
end
|
47
|
-
|
48
|
-
##########
|
49
|
-
# push #
|
50
|
-
##########
|
51
|
-
|
52
|
-
it 'can add elements' do
|
53
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
54
|
-
array_instance.push( :some_setting )
|
55
|
-
array_instance.should == [ :some_setting ]
|
56
|
-
array_instance.exclude_array.include?( :some_setting ).should == false
|
57
|
-
array_instance.push( :other_setting )
|
58
|
-
array_instance.should == [ :other_setting, :some_setting ]
|
59
|
-
array_instance.exclude_array.include?( :other_setting ).should == false
|
60
|
-
end
|
61
|
-
|
62
|
-
############
|
63
|
-
# concat #
|
64
|
-
############
|
65
|
-
|
66
|
-
it 'can concat arrays' do
|
67
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
68
|
-
array_instance.concat( [ :some_setting ] )
|
69
|
-
array_instance.should == [ :some_setting ]
|
70
|
-
array_instance.exclude_array.include?( :some_setting ).should == false
|
71
|
-
array_instance.concat( [ :other_setting ] )
|
72
|
-
array_instance.should == [ :other_setting, :some_setting ]
|
73
|
-
array_instance.exclude_array.include?( :other_setting ).should == false
|
74
|
-
end
|
75
|
-
|
76
|
-
#######
|
77
|
-
# - #
|
78
|
-
#######
|
79
|
-
|
80
|
-
it 'can exclude elements' do
|
81
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
82
|
-
array_instance += [ :some_setting, :other_setting ]
|
83
|
-
array_instance -= [ :other_setting ]
|
84
|
-
array_instance.should == [ :some_setting ]
|
85
|
-
array_instance.exclude_array.include?( :other_setting ).should == true
|
86
|
-
array_instance -= [ :some_setting ]
|
87
|
-
array_instance.should == []
|
88
|
-
array_instance.exclude_array.include?( :some_setting ).should == true
|
89
|
-
end
|
90
|
-
|
91
|
-
############
|
92
|
-
# delete #
|
93
|
-
############
|
94
|
-
|
95
|
-
it 'can exclude elements' do
|
96
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
97
|
-
array_instance += [ :some_setting, :other_setting ]
|
98
|
-
array_instance.delete( :other_setting )
|
99
|
-
array_instance.should == [ :some_setting ]
|
100
|
-
array_instance.exclude_array.include?( :other_setting ).should == true
|
101
|
-
array_instance.delete( :some_setting )
|
102
|
-
array_instance.should == []
|
103
|
-
array_instance.exclude_array.include?( :some_setting ).should == true
|
104
|
-
end
|
105
|
-
|
106
|
-
#########
|
107
|
-
# pop #
|
108
|
-
#########
|
109
|
-
|
110
|
-
it 'can pop the final element' do
|
111
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
112
|
-
array_instance += [ :other_setting, :some_setting ]
|
113
|
-
array_instance.pop.should == :some_setting
|
114
|
-
array_instance.should == [ :other_setting ]
|
115
|
-
array_instance.exclude_array.include?( :some_setting ).should == true
|
116
|
-
end
|
117
|
-
|
118
|
-
###########
|
119
|
-
# shift #
|
120
|
-
###########
|
121
|
-
|
122
|
-
it 'can shift the first element' do
|
123
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
124
|
-
array_instance += [ :other_setting, :some_setting ]
|
125
|
-
array_instance.shift.should == :other_setting
|
126
|
-
array_instance.should == [ :some_setting ]
|
127
|
-
array_instance.exclude_array.include?( :other_setting ).should == true
|
128
|
-
end
|
129
|
-
|
130
|
-
############
|
131
|
-
# slice! #
|
132
|
-
############
|
133
|
-
|
134
|
-
it 'can slice elements' do
|
135
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
136
|
-
array_instance += [ :other_setting, :some_setting ]
|
137
|
-
array_instance.slice!( 0, 1 ).should == [ :other_setting ]
|
138
|
-
array_instance.should == [ :some_setting ]
|
139
|
-
array_instance.exclude_array.include?( :other_setting ).should == true
|
140
|
-
end
|
141
|
-
|
142
|
-
###########
|
143
|
-
# clear #
|
144
|
-
###########
|
145
|
-
|
146
|
-
it 'can clear, causing present elements to be excluded' do
|
147
|
-
array_instance = CascadingConfiguration::Array::CompositingArray::LocalConfigurationArray.new
|
148
|
-
array_instance += [ :some_setting, :other_setting ]
|
149
|
-
array_instance.clear
|
150
|
-
array_instance.should == []
|
151
|
-
array_instance.exclude_array.include?( :some_setting ).should == true
|
152
|
-
array_instance.exclude_array.include?( :other_setting ).should == true
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|