cascading-configuration-array 1.1.3 → 1.1.4

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.
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 3
9
- version: 1.1.3
8
+ - 4
9
+ version: 1.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Asher
@@ -39,20 +39,9 @@ extensions: []
39
39
  extra_rdoc_files: []
40
40
 
41
41
  files:
42
- - lib/cascading-configuration-array/CascadingConfiguration/_private_/CompositingArray.rb
43
- - lib/cascading-configuration-array/CascadingConfiguration/_private_/LocalConfigurationArray.rb
44
- - lib/cascading-configuration-array/CascadingConfiguration/Array/Accessors.rb
45
- - lib/cascading-configuration-array/CascadingConfiguration/Array/ClassInstance.rb
46
- - lib/cascading-configuration-array/CascadingConfiguration/Array/ModuleInstance.rb
47
- - lib/cascading-configuration-array/CascadingConfiguration/Array.rb
48
- - lib/cascading-configuration-array/CascadingConfiguration/CompositingArray/Instance.rb
49
- - lib/cascading-configuration-array/CascadingConfiguration/CompositingArray.rb
50
- - lib/cascading-configuration-array/CascadingConfiguration/LocalConfigurationArray.rb
51
- - lib/cascading-configuration-array.rb
52
- - spec/CascadingConfiguration/Array/Accessors_spec.rb
53
- - spec/CascadingConfiguration/Array_spec.rb
54
- - spec/CascadingConfiguration/CompositingArray_spec.rb
55
- - spec/CascadingConfiguration/LocalConfigurationArray_spec.rb
42
+ - lib/cascading-configuration/CascadingConfiguration.rb
43
+ - lib/cascading-configuration.rb
44
+ - spec/CascadingConfiguration_spec.rb
56
45
  - README.md
57
46
  - README.rdoc
58
47
  has_rdoc: true
@@ -1,38 +0,0 @@
1
-
2
- module CascadingConfiguration::Array::Accessors
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- ###################################
7
- # define_cascading_array_setter #
8
- ###################################
9
-
10
- def define_cascading_array_setter( configuration_name )
11
- configuration_setter_name = ( configuration_name.to_s + '=' ).to_sym
12
- self::AccessorSupportModule.module_eval do
13
- define_method( configuration_setter_name ) do |array|
14
- composite_array = composite_array_for_cascading_configuration( configuration_name )
15
- # we want the array to supplant existing config
16
- # clear the array (excludes everything explicitly)
17
- composite_array.clear
18
- # push array elements (removes anything excluded from exclude)
19
- composite_array.push( *array )
20
- return composite_array
21
- end
22
- end
23
- end
24
-
25
- ###################################
26
- # define_cascading_array_getter #
27
- ###################################
28
-
29
- def define_cascading_array_getter( configuration_name )
30
- configuration_getter_name = configuration_name
31
- self::AccessorSupportModule.module_eval do
32
- define_method( configuration_getter_name ) do
33
- return composite_array_for_cascading_configuration( configuration_name )
34
- end
35
- end
36
- end
37
-
38
- end
@@ -1,19 +0,0 @@
1
-
2
- module CascadingConfiguration::Array::ClassInstance
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- ##############################
7
- # attr_configuration_array #
8
- ##############################
9
-
10
- def attr_configuration_array( *property_names )
11
- property_names.each do |this_property_name|
12
- # define configuration setter
13
- define_cascading_array_setter( this_property_name )
14
- # define configuration getter
15
- define_cascading_array_getter( this_property_name )
16
- end
17
- end
18
-
19
- end
@@ -1,36 +0,0 @@
1
-
2
- module CascadingConfiguration::Array::ModuleInstance
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- ##############
7
- # included #
8
- ##############
9
-
10
- def included( class_or_module )
11
- super if method_defined?( :super )
12
- # CascadingConfiguration::Array
13
- module_self = self
14
- class_or_module.instance_eval do
15
- # whichever module included CascadingConfiguration::Array
16
- extend module_self
17
- # cascade CascadingConfiguration::Array
18
- include CascadingConfiguration::Array
19
- end
20
- end
21
-
22
- ##############
23
- # extended #
24
- ##############
25
-
26
- def extended( class_or_module )
27
- super if method_defined?( :super )
28
- # CascadingConfiguration::Array
29
- module_self = self
30
- class_or_module.instance_eval do
31
- # cascade CascadingConfiguration::Array
32
- include CascadingConfiguration::Array
33
- end
34
- end
35
-
36
- end
@@ -1,24 +0,0 @@
1
-
2
- module CascadingConfiguration::Array
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- include CascadingConfiguration::Variable
7
- include CascadingConfiguration::CompositingArray::Instance
8
-
9
- ###################
10
- # self.included #
11
- ###################
12
-
13
- def self.included( class_or_module )
14
- module_self = self
15
- class_or_module.instance_eval do
16
- extend module_self
17
- extend module_self::Accessors
18
- extend module_self::ClassInstance
19
- # module support
20
- extend CascadingConfiguration::Array::ModuleInstance unless is_a?( Class )
21
- end
22
- end
23
-
24
- end
@@ -1,39 +0,0 @@
1
-
2
- module CascadingConfiguration::CompositingArray::Instance
3
-
4
- extend CascadingConfiguration::InternalModuleStub
5
-
6
- ###################
7
- # self.included #
8
- ###################
9
-
10
- def self.included( class_or_module )
11
- module_self = self
12
- class_or_module.instance_eval do
13
- extend module_self
14
- end
15
- end
16
-
17
- #################################################
18
- # composite_array_for_cascading_configuration #
19
- #################################################
20
-
21
- def composite_array_for_cascading_configuration( cascading_name )
22
-
23
- composite_array = nil
24
-
25
- klass = ( is_a?( Module ) ? self : self.class )
26
- accessor_support_module = klass::AccessorSupportModule
27
- self_instance = self
28
- accessor_support_module.instance_eval do
29
- unless composite_array = ( ( @composite_arrays ||= Hash.new )[ cascading_name ] ||= Hash.new )[ self_instance ]
30
- composite_array = ::CascadingConfiguration::CompositingArray.new( cascading_name, self_instance )
31
- @composite_arrays[ cascading_name ][ self_instance ] = composite_array
32
- end
33
- end
34
-
35
- return composite_array
36
-
37
- end
38
-
39
- end
@@ -1,216 +0,0 @@
1
-
2
- class CascadingConfiguration::CompositingArray < Array
3
-
4
- attr_accessor :working_instance, :local_cascading_array
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
- @cascading_variable = working_class::AccessorSupportModule.cascading_variable_name( @cascading_name )
14
- @working_instance = working_instance
15
- # if first ancestor can have a composite array, register self with it in case it gets updated in the future
16
- if ( first_ancestor = @working_instance.first_ancestor ).respond_to?( :composite_array_for_cascading_configuration )
17
- @parent_composite_array = first_ancestor.composite_array_for_cascading_configuration( @cascading_name )
18
- @parent_composite_array.register_child_composite_array( self )
19
- end
20
- # get local cascading array (not included in parent composite)
21
- @local_cascading_array = ::CascadingConfiguration::LocalConfigurationArray.new
22
- # we may later have our own child composites
23
- @child_composite_arrays = ::Array.new
24
- # initialize self status for parent and local
25
- update_self_as_cascading_composite
26
- end
27
-
28
- ####################################
29
- # register_child_composite_array #
30
- ####################################
31
-
32
- def register_child_composite_array( child_composite_array )
33
- @child_composite_arrays.push( child_composite_array )
34
- return self
35
- end
36
-
37
- ######################################
38
- # unregister_child_composite_array #
39
- ######################################
40
-
41
- def unregister_child_composite_array( child_composite_array )
42
- @child_composite_arrays.delete( child_composite_array )
43
- return self
44
- end
45
-
46
- #########
47
- # []= #
48
- #########
49
-
50
- def []=( index, element )
51
- # we sort internally, so index is irrelevant
52
- # no reason to differentiate from push
53
- push( element )
54
- end
55
-
56
- ########
57
- # << #
58
- ########
59
-
60
- def <<( *elements )
61
- # no reason to differentiate from push
62
- push( *elements )
63
- end
64
-
65
- #######
66
- # + #
67
- #######
68
-
69
- def +( *arrays )
70
- # no reason to differentiate from push
71
- arrays.each do |this_array|
72
- push( *this_array )
73
- end
74
- return self
75
- end
76
-
77
- ############
78
- # concat #
79
- ############
80
-
81
- def concat( *arrays )
82
- arrays.each do |this_array|
83
- push( *this_array )
84
- end
85
- end
86
-
87
- ##########
88
- # push #
89
- ##########
90
-
91
- alias_method :super_push, :push
92
- def push( *elements )
93
-
94
- # we are a composite array
95
- # that means we have to set the value for our class
96
- @local_cascading_array.push( *elements )
97
-
98
- update_adding_composite_elements( *elements )
99
-
100
- return self
101
-
102
- end
103
-
104
- #######
105
- # - #
106
- #######
107
-
108
- def -( *arrays )
109
-
110
- arrays.each do |this_array|
111
- delete( *this_array )
112
- end
113
-
114
- return self
115
-
116
- end
117
-
118
- ############
119
- # delete #
120
- ############
121
-
122
- alias_method :super_delete, :delete
123
- def delete( *elements )
124
-
125
- @local_cascading_array.delete( *elements )
126
-
127
- update_removing_composite_elements( *elements )
128
-
129
- return self
130
-
131
- end
132
-
133
- #########
134
- # pop #
135
- #########
136
-
137
- def pop
138
-
139
- element = super
140
-
141
- @local_cascading_array.delete( element )
142
-
143
- update_removing_composite_elements( element )
144
-
145
- return element
146
-
147
- end
148
-
149
- ###########
150
- # shift #
151
- ###########
152
-
153
- def shift
154
-
155
- element = super
156
-
157
- @local_cascading_array.delete( element )
158
-
159
- update_removing_composite_elements( element )
160
-
161
- return element
162
-
163
- end
164
-
165
- ############
166
- # slice! #
167
- ############
168
-
169
- def slice!( *args )
170
-
171
- elements = super
172
-
173
- @local_cascading_array.delete( *elements )
174
-
175
- update_removing_composite_elements( *elements )
176
-
177
- return elements
178
-
179
- end
180
-
181
- ###########
182
- # clear #
183
- ###########
184
-
185
- alias_method :super_clear, :clear
186
- def clear
187
-
188
- # add all existing values to exclude array
189
- @local_cascading_array.delete( *self )
190
-
191
- update_removing_composite_elements( *self )
192
-
193
- return self
194
-
195
- end
196
-
197
- #############
198
- # freeze! #
199
- #############
200
-
201
- # freezes configuration and prevents ancestors from changing this configuration in the future
202
- def freeze!
203
-
204
- # move current configuration into local configuration
205
- @local_cascading_array.clear
206
- @local_cascading_array.exclude_array.clear
207
- @local_cascading_array.push( *self )
208
-
209
- # unregister with parent composite so we don't get future updates from it
210
- @parent_composite_array.unregister_child_composite_array( self ) if @parent_composite_array
211
-
212
- return self
213
-
214
- end
215
-
216
- end
@@ -1,166 +0,0 @@
1
-
2
- class CascadingConfiguration::LocalConfigurationArray < Array
3
-
4
- attr_accessor :exclude_array
5
-
6
- ################
7
- # initialize #
8
- ################
9
-
10
- def initialize()
11
- @exclude_array = ::Array.new
12
- end
13
-
14
- #########
15
- # []= #
16
- #########
17
-
18
- def []=( index, element )
19
- # we sort internally, so index is irrelevant
20
- # no reason to differentiate from push
21
- push( element )
22
- end
23
-
24
- ########
25
- # << #
26
- ########
27
-
28
- def <<( *elements )
29
- # no reason to differentiate from push
30
- push( *elements )
31
- end
32
-
33
- #######
34
- # + #
35
- #######
36
-
37
- def +( *element_arrays )
38
- element_arrays.each do |this_element_array|
39
- push( *this_element_array )
40
- end
41
- return self
42
- end
43
-
44
- ##########
45
- # push #
46
- ##########
47
-
48
- def push( *elements )
49
-
50
- # add elements to configuration array
51
- super
52
-
53
- # sort and uniq self
54
- sort!.uniq!
55
-
56
- # make sure we don't still have any elements noted as excluded at this level
57
- remove_from_exclude_array( *elements )
58
-
59
- return self
60
-
61
- end
62
-
63
- ############
64
- # concat #
65
- ############
66
-
67
- def concat( *arrays )
68
-
69
- arrays.each do |this_array|
70
- push( *this_array )
71
- end
72
-
73
- return self
74
-
75
- end
76
-
77
- #######
78
- # - #
79
- #######
80
-
81
- def -( *arrays )
82
-
83
- arrays.each do |this_array|
84
- delete( *this_array )
85
- end
86
-
87
- return self
88
-
89
- end
90
-
91
- ############
92
- # delete #
93
- ############
94
-
95
- def delete( *elements )
96
-
97
- elements.each do |this_element|
98
- super( this_element )
99
- end
100
- # add subtracted elements to exclude array
101
- add_to_exclude_array( *elements )
102
-
103
- return self
104
-
105
- end
106
-
107
- #########
108
- # pop #
109
- #########
110
-
111
- def pop
112
-
113
- element = super
114
-
115
- # add popped element to exclude array
116
- add_to_exclude_array( element )
117
-
118
- return element
119
-
120
- end
121
-
122
- ###########
123
- # shift #
124
- ###########
125
-
126
- def shift
127
-
128
- element = super
129
-
130
- # add shifted element to exclude array
131
- add_to_exclude_array( element )
132
-
133
- return element
134
-
135
- end
136
-
137
- ############
138
- # slice! #
139
- ############
140
-
141
- def slice!( *args )
142
-
143
- elements = super
144
-
145
- # add sliced elements to exclude array
146
- delete( *elements )
147
-
148
- return elements
149
-
150
- end
151
-
152
- ###########
153
- # clear #
154
- ###########
155
-
156
- def clear
157
-
158
- # add all existing values to exclude array
159
- delete( *self )
160
-
161
- # clear existing values
162
- super
163
-
164
- end
165
-
166
- end
@@ -1,57 +0,0 @@
1
-
2
- class CascadingConfiguration::CompositingArray < Array
3
-
4
- ###########################################################################################################
5
- private ###############################################################################################
6
- ###########################################################################################################
7
-
8
- ########################################
9
- # update_self_as_cascading_composite #
10
- ########################################
11
-
12
- def update_self_as_cascading_composite
13
- # start fresh
14
- super_clear
15
- # add parent config
16
- super_push( *@parent_composite_array ) if @parent_composite_array
17
- # add additional local config
18
- super_push( *@local_cascading_array )
19
- # remove local exclude
20
- super_delete( *@local_cascading_array.exclude_array ) unless @local_cascading_array.exclude_array.empty?
21
- # notify children to update their composite status
22
- update_child_composite_arrays
23
- return self
24
- end
25
-
26
- ######################################
27
- # update_adding_composite_elements #
28
- ######################################
29
-
30
- def update_adding_composite_elements( *elements_to_cascade )
31
- super_push( *elements_to_cascade )
32
- sort!.uniq!
33
- update_child_composite_arrays
34
- end
35
-
36
- ########################################
37
- # update_removing_composite_elements #
38
- ########################################
39
-
40
- def update_removing_composite_elements( *elements_to_exclude )
41
- elements_to_exclude.each do |this_excluded_element|
42
- super_delete( this_excluded_element )
43
- end
44
- update_child_composite_arrays
45
- end
46
-
47
- ###################################
48
- # update_child_composite_arrays #
49
- ###################################
50
-
51
- def update_child_composite_arrays
52
- @child_composite_arrays.each do |this_composite_array|
53
- this_composite_array.instance_eval { update_self_as_cascading_composite }
54
- end
55
- end
56
-
57
- end
@@ -1,26 +0,0 @@
1
-
2
- class CascadingConfiguration::LocalConfigurationArray < Array
3
-
4
- ###########################################################################################################
5
- private ###############################################################################################
6
- ###########################################################################################################
7
-
8
- ##########################
9
- # add_to_exclude_array #
10
- ##########################
11
-
12
- def add_to_exclude_array( *elements )
13
- @exclude_array += elements
14
- @exclude_array.sort!.uniq!
15
- end
16
-
17
- ###############################
18
- # remove_from_exclude_array #
19
- ###############################
20
-
21
- def remove_from_exclude_array( *elements )
22
- @exclude_array -= elements
23
- @exclude_array.sort!.uniq!
24
- end
25
-
26
- end
@@ -1,35 +0,0 @@
1
-
2
- if $cascading_configuration_development
3
- require_relative '../../variable/lib/cascading-configuration-variable.rb'
4
- else
5
- require 'cascading-configuration-variable'
6
- end
7
-
8
- module CascadingConfiguration
9
- class CompositingArray < Array
10
- module Instance
11
- end
12
- end
13
- class LocalConfigurationArray < Array
14
- end
15
- module Array
16
- module Accessors
17
- end
18
- module ClassInstance
19
- end
20
- module ObjectInstance
21
- end
22
- module ModuleInstance
23
- end
24
- end
25
- end
26
-
27
- require_relative 'cascading-configuration-array/CascadingConfiguration/CompositingArray.rb'
28
- require_relative 'cascading-configuration-array/CascadingConfiguration/_private_/CompositingArray.rb'
29
- require_relative 'cascading-configuration-array/CascadingConfiguration/CompositingArray/Instance.rb'
30
- require_relative 'cascading-configuration-array/CascadingConfiguration/LocalConfigurationArray.rb'
31
- require_relative 'cascading-configuration-array/CascadingConfiguration/_private_/LocalConfigurationArray.rb'
32
- require_relative 'cascading-configuration-array/CascadingConfiguration/Array.rb'
33
- require_relative 'cascading-configuration-array/CascadingConfiguration/Array/Accessors.rb'
34
- require_relative 'cascading-configuration-array/CascadingConfiguration/Array/ClassInstance.rb'
35
- require_relative 'cascading-configuration-array/CascadingConfiguration/Array/ModuleInstance.rb'