cascading_configuration 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -108,7 +108,7 @@ Whether Hashes or Arrays, the idea is the same. We call the Compositing Objects.
108
108
  2. The compositing object is initialized (separately) for its immediate parent object.
109
109
  3. Whenever an update occurs, the compositing object updates its registered child object with the update.
110
110
 
111
- This way the lower objects are kept in sync with parent elements. Overriding hooked methods (provided by HookedArray from the hooked-array gem) provides a great deal of flexible functionality, permitting elements to be transformed as they are passed down the ancestor hierarchy.
111
+ This way the lower objects are kept in sync with parent elements. Overriding hooked methods (provided by Array::Hooked from the array-hooked gem) provides a great deal of flexible functionality, permitting elements to be transformed as they are passed down the ancestor hierarchy.
112
112
 
113
113
  Right now there are 5 types of Compositing Objects:
114
114
 
@@ -97,7 +97,7 @@ module ::CascadingConfiguration::Array::Sorted::Unique
97
97
 
98
98
  sorted_unique_array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
99
99
  CompositingObjects.new( :sorted_unique_array,
100
- ::CompositingArray::Sorted::Unique,
100
+ ::Array::Sorted::Unique::Compositing,
101
101
  :default,
102
102
  :unique_sorted_array,
103
103
  :configuration_sorted_unique_array,
@@ -97,7 +97,7 @@ module ::CascadingConfiguration::Array::Sorted
97
97
 
98
98
  sorted_array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
99
99
  CompositingObjects.new( :sorted_array,
100
- ::CompositingArray::Sorted,
100
+ ::Array::Sorted::Compositing,
101
101
  :default,
102
102
  :configuration_sorted_array )
103
103
 
@@ -97,7 +97,7 @@ module ::CascadingConfiguration::Array::Unique
97
97
 
98
98
  unique_array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
99
99
  CompositingObjects.new( :unique_array,
100
- ::CompositingArray::Unique,
100
+ ::Array::Unique::Compositing,
101
101
  :default,
102
102
  :configuration_unique_array )
103
103
 
@@ -96,7 +96,7 @@ module ::CascadingConfiguration::Array
96
96
  #
97
97
 
98
98
  array_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
99
- CompositingObjects.new( :array, ::CompositingArray, :default, :configuration_array )
99
+ CompositingObjects.new( :array, ::Array::Compositing, :default, :configuration_array )
100
100
 
101
101
  ::CascadingConfiguration::Core.enable( self, array_module )
102
102
 
@@ -149,7 +149,7 @@ class ::CascadingConfiguration::Core::Encapsulation < ::Module
149
149
  def register_child_for_parent( child, parent )
150
150
 
151
151
  super
152
-
152
+
153
153
  # Modules already have configurations and if parent already has configurations
154
154
  unless parent.is_a?( ::Module ) or has_parents?( parent )
155
155
  register_child_for_parent( parent, parent.class )
@@ -21,8 +21,8 @@ class ::CascadingConfiguration::Core::InstanceController::SupportModule < ::Modu
21
21
  @encapsulation = encapsulation
22
22
  @module_type_name = module_type_name
23
23
 
24
- @included = ::UniqueArray.new( self )
25
- @extended = ::UniqueArray.new( self )
24
+ @included = ::Array::Unique.new( self )
25
+ @extended = ::Array::Unique.new( self )
26
26
 
27
27
  # include modules like ourselves above us
28
28
  existing_super_modules = super_modules
@@ -103,8 +103,8 @@ class ::CascadingConfiguration::Core::InstanceController < ::Module
103
103
  # We also support arbitrary additional encapsulations.
104
104
  @encapsulations = { }
105
105
 
106
- @cascade_includes = ::UniqueArray.new( self )
107
- @cascade_extends = ::UniqueArray.new( self )
106
+ @cascade_includes = ::Array::Unique.new( self )
107
+ @cascade_extends = ::Array::Unique.new( self )
108
108
 
109
109
  @support_modules = { }
110
110
 
@@ -119,7 +119,7 @@ class ::CascadingConfiguration::Core::InstanceController < ::Module
119
119
  def initialize_inheriting_instance( parent_instance, instance, for_subclass = false, is_extending = false )
120
120
 
121
121
  super
122
-
122
+
123
123
  initialize_encapsulation_for_inheriting_instance( @default_encapsulation, parent_instance, instance )
124
124
  @encapsulations.each do |this_encapsulation_name, this_encapsulation|
125
125
  initialize_encapsulations_for_inheriting_instance( this_encapsulation, parent_instance, instance )
@@ -135,8 +135,13 @@ class ::CascadingConfiguration::Core::InstanceController < ::Module
135
135
  unless @cascade_includes.empty?
136
136
  if is_extending
137
137
  @cascade_includes.each do |this_include|
138
- unless instance.ancestors.include?( this_include )
139
- include.extend( this_include )
138
+ case instance
139
+ when ::Module
140
+ unless instance.ancestors.include?( this_include )
141
+ instance.extend( this_include )
142
+ end
143
+ else
144
+ instance.extend( this_include )
140
145
  end
141
146
  end
142
147
  elsif instance.is_a?( ::Module )
@@ -14,9 +14,10 @@ module ::CascadingConfiguration::Core
14
14
  # Enable module instance so that when included it creates instance support
15
15
  instance.extend( ::CascadingConfiguration::Core::EnableInstanceSupport )
16
16
 
17
- instance.extend( ::ModuleCluster )
17
+ instance.extend( ::Module::Cluster )
18
18
 
19
- instance.include_or_extend_also_extends( instance::ClassInstance )
19
+ instance.cluster( :cascading_configuration ).after_include.extend( instance::ClassInstance )
20
+ instance.cluster( :cascading_configuration ).after_extend.extend( instance::ClassInstance )
20
21
 
21
22
  end
22
23
 
@@ -96,7 +96,7 @@ module ::CascadingConfiguration::Hash
96
96
  #
97
97
 
98
98
  hash_module = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::
99
- CompositingObjects.new( :hash, ::CompositingHash, :default, :configuration_hash )
99
+ CompositingObjects.new( :hash, ::Hash::Compositing, :default, :configuration_hash )
100
100
 
101
101
  ::CascadingConfiguration::Core.enable( self, hash_module )
102
102
 
@@ -1,4 +1,6 @@
1
1
 
2
+ begin ; require 'development' ; rescue ::LoadError ; end
3
+
2
4
  # namespaces that have to be declared ahead of time for proper load order
3
5
  require_relative './namespaces'
4
6
 
data/lib/requires.rb CHANGED
@@ -1,10 +1,10 @@
1
- require 'to_camel_case'
2
- require 'accessor-utilities'
3
- require 'parallel-ancestry'
4
- require 'compositing-hash'
5
- require 'compositing-array-sorted-unique'
1
+ begin ; require 'development' ; rescue ::LoadError ; end
6
2
 
7
- #require_relative '../../compositing_objects/compositing-hash/lib/compositing-hash.rb'
3
+ require 'to_camel_case'
4
+ require 'accessor_utilities'
5
+ require 'parallel_ancestry'
6
+ require 'hash'
7
+ require 'array'
8
8
 
9
9
  basepath = 'cascading_configuration'
10
10
 
@@ -132,79 +132,87 @@ describe ::CascadingConfiguration::Core::InstanceController do
132
132
  InstanceController = ::CascadingConfiguration::Core::InstanceController.new( ForInstance )
133
133
 
134
134
  # should_include
135
- ModuleInstance_Include = InstanceController.create_support( :some_type1, Encapsulation, nil, true, false, false, false )
136
- InstanceController.support( :some_type1 ).should == ModuleInstance_Include
135
+ ModuleInstance_Include = InstanceController.create_support( :include, Encapsulation, nil, true, false, false, false )
136
+ InstanceController.support( :include ).should == ModuleInstance_Include
137
137
  ForInstance.ancestors.include?( ModuleInstance_Include ).should == true
138
138
  ForInstance.is_a?( ModuleInstance_Include ).should == false
139
139
  InstanceController.cascade_includes.include?( ModuleInstance_Include ).should == false
140
140
  InstanceController.cascade_extends.include?( ModuleInstance_Include ).should == false
141
141
 
142
142
  # should_extend
143
- ModuleInstance_Extend = InstanceController.create_support( :some_type2, Encapsulation, false, nil, true, false, false )
144
- InstanceController.support( :some_type2 ).should == ModuleInstance_Extend
143
+ ModuleInstance_Extend = InstanceController.create_support( :extend, Encapsulation, false, nil, true, false, false )
144
+ InstanceController.support( :extend ).should == ModuleInstance_Extend
145
145
  ForInstance.ancestors.include?( ModuleInstance_Extend ).should == false
146
146
  ForInstance.is_a?( ModuleInstance_Extend ).should == true
147
147
  InstanceController.cascade_includes.include?( ModuleInstance_Extend ).should == false
148
148
  InstanceController.cascade_extends.include?( ModuleInstance_Extend ).should == false
149
149
 
150
150
  # should_cascade_includes
151
- ModuleInstance_CascadeIncludes = InstanceController.create_support( :some_type3, Encapsulation, false, nil, false, true, false )
152
- InstanceController.support( :some_type3 ).should == ModuleInstance_CascadeIncludes
151
+ ModuleInstance_CascadeIncludes = InstanceController.create_support( :cascade_includes, Encapsulation, false, nil, false, true, false )
152
+ InstanceController.support( :cascade_includes ).should == ModuleInstance_CascadeIncludes
153
153
  ForInstance.ancestors.include?( ModuleInstance_CascadeIncludes ).should == false
154
154
  ForInstance.is_a?( ModuleInstance_CascadeIncludes ).should == false
155
155
  InstanceController.cascade_includes.include?( ModuleInstance_CascadeIncludes ).should == true
156
156
  InstanceController.cascade_extends.include?( ModuleInstance_CascadeIncludes ).should == false
157
157
 
158
158
  # should_cascade_extends
159
- ModuleInstance_CascadeExtends = InstanceController.create_support( :some_type4, Encapsulation, nil, false, false, false, true )
160
- InstanceController.support( :some_type4 ).should == ModuleInstance_CascadeExtends
159
+ ModuleInstance_CascadeExtends = InstanceController.create_support( :cascade_extends, Encapsulation, nil, false, false, false, true )
160
+ InstanceController.support( :cascade_extends ).should == ModuleInstance_CascadeExtends
161
161
  ForInstance.ancestors.include?( ModuleInstance_CascadeExtends ).should == false
162
162
  ForInstance.is_a?( ModuleInstance_CascadeExtends ).should == false
163
163
  InstanceController.cascade_includes.include?( ModuleInstance_CascadeExtends ).should == false
164
164
  InstanceController.cascade_extends.include?( ModuleInstance_CascadeExtends ).should == true
165
165
 
166
- AnotherModule_IncludeA = ::Module.new do
166
+ AnotherModule_IncludeA = ::Module.new
167
+ AnotherModule_IncludeA.instance_eval do
167
168
  include ForInstance
168
169
  ancestors.include?( ModuleInstance_CascadeIncludes ).should == true
169
170
  eigenclass = class << self ; self ; end
170
171
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == true
171
172
  end
172
- AnotherModule_IncludeB = ::Module.new do
173
+ AnotherModule_IncludeB = ::Module.new
174
+ AnotherModule_IncludeB.instance_eval do
173
175
  include AnotherModule_IncludeA
174
176
  ancestors.include?( ModuleInstance_CascadeIncludes ).should == true
175
177
  eigenclass = class << self ; self ; end
176
178
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == true
177
179
  end
178
- AnotherModule_IncludeC = ::Module.new do
180
+ AnotherModule_IncludeC = ::Module.new
181
+ AnotherModule_IncludeC.instance_eval do
179
182
  include AnotherModule_IncludeB
180
183
  ancestors.include?( ModuleInstance_CascadeIncludes ).should == true
181
184
  eigenclass = class << self ; self ; end
182
185
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == true
183
186
  end
184
- AnotherModule_ClassInclude = ::Class.new do
187
+ AnotherModule_ClassInclude = ::Class.new
188
+ AnotherModule_ClassInclude.instance_eval do
185
189
  include AnotherModule_IncludeC
186
190
  ancestors.include?( ModuleInstance_CascadeIncludes ).should == true
187
191
  eigenclass = class << self ; self ; end
188
192
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == true
189
193
  end
190
194
 
191
- AnotherModule_ExtendA = ::Module.new do
195
+ AnotherModule_ExtendA = ::Module.new
196
+ AnotherModule_ExtendA.instance_eval do
192
197
  extend ForInstance
193
198
  eigenclass = class << self ; self ; end
194
199
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == false
195
200
  eigenclass.ancestors.include?( ModuleInstance_CascadeIncludes ).should == true
196
201
  end
197
- AnotherModule_ExtendB = ::Module.new do
202
+ AnotherModule_ExtendB = ::Module.new
203
+ AnotherModule_ExtendB.instance_eval do
198
204
  extend AnotherModule_ExtendA
199
205
  eigenclass = class << self ; self ; end
200
206
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == false
201
207
  end
202
- AnotherModule_ExtendC = ::Module.new do
208
+ AnotherModule_ExtendC = ::Module.new
209
+ AnotherModule_ExtendC.instance_eval do
203
210
  extend AnotherModule_ExtendB
204
211
  eigenclass = class << self ; self ; end
205
212
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == false
206
213
  end
207
- AnotherModule_ClassExtend = ::Class.new do
214
+ AnotherModule_ClassExtend = ::Class.new
215
+ AnotherModule_ClassExtend.instance_eval do
208
216
  extend AnotherModule_ExtendC
209
217
  eigenclass = class << self ; self ; end
210
218
  eigenclass.ancestors.include?( ModuleInstance_CascadeExtends ).should == false
@@ -10,14 +10,14 @@ describe ::CascadingConfiguration::Core::Module::ExtendedConfigurations::Composi
10
10
 
11
11
  it 'can initialize with a compositing object class' do
12
12
  module ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects::InitializeMock
13
- ClassInstance = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects.new( :setting, ::CompositingArray, :default, '' )
13
+ ClassInstance = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects.new( :setting, ::Array::Compositing, :default, '' )
14
14
  CCM = ::Module.new do
15
15
  ::CascadingConfiguration::Core.enable( self, ClassInstance )
16
16
  end
17
17
  CCM::ClassInstance.default_encapsulation.should == ::CascadingConfiguration::Core::Module::DefaultEncapsulation
18
18
  CCM::ClassInstance.ccm_name.should == :setting
19
19
  CCM::ClassInstance.ccm_aliases.should == [ '' ]
20
- CCM::ClassInstance.compositing_object_class.should == ::CompositingArray
20
+ CCM::ClassInstance.compositing_object_class.should == ::Array::Compositing
21
21
  end
22
22
  end
23
23
 
@@ -29,7 +29,7 @@ describe ::CascadingConfiguration::Core::Module::ExtendedConfigurations::Composi
29
29
  it 'ensures objects are initialized for each level in hiearchy' do
30
30
  module ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects::CreateConfigurationMock
31
31
 
32
- ClassInstance = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects.new( :setting, ::CompositingArray, :default, '' )
32
+ ClassInstance = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects.new( :setting, ::Array::Compositing, :default, '' )
33
33
  CCM = ::Module.new do
34
34
  ::CascadingConfiguration::Core.enable( self, ClassInstance )
35
35
  end
@@ -41,42 +41,42 @@ describe ::CascadingConfiguration::Core::Module::ExtendedConfigurations::Composi
41
41
  include CCM
42
42
  attr_setting :some_configuration
43
43
  end
44
- Encapsulation.get_configuration( Module1, :some_configuration ).is_a?( ::CompositingArray ).should == true
44
+ Encapsulation.get_configuration( Module1, :some_configuration ).is_a?( ::Array::Compositing ).should == true
45
45
 
46
46
  # module 2
47
47
  Module2 = ::Module.new do
48
48
  include Module1
49
49
  end
50
- Encapsulation.get_configuration( Module2, :some_configuration ).is_a?( ::CompositingArray ).should == true
50
+ Encapsulation.get_configuration( Module2, :some_configuration ).is_a?( ::Array::Compositing ).should == true
51
51
 
52
52
  # module 3
53
53
  Module3 = ::Module.new do
54
54
  include Module2
55
55
  end
56
- Encapsulation.get_configuration( Module3, :some_configuration ).is_a?( ::CompositingArray ).should == true
56
+ Encapsulation.get_configuration( Module3, :some_configuration ).is_a?( ::Array::Compositing ).should == true
57
57
 
58
58
  # class 1
59
59
  Class1 = ::Class.new do
60
60
  include Module3
61
61
  end
62
- Encapsulation.get_configuration( Class1, :some_configuration ).is_a?( ::CompositingArray ).should == true
62
+ Encapsulation.get_configuration( Class1, :some_configuration ).is_a?( ::Array::Compositing ).should == true
63
63
 
64
64
  # subclass 1
65
65
  Class2 = ::Class.new( Class1 )
66
- Encapsulation.get_configuration( Class2, :some_configuration ).is_a?( ::CompositingArray ).should == true
66
+ Encapsulation.get_configuration( Class2, :some_configuration ).is_a?( ::Array::Compositing ).should == true
67
67
 
68
68
  # instance
69
69
  Instance = Class2.new
70
70
  Encapsulation.get_configuration( Instance, :some_configuration ).nil?.should == true
71
- Instance.some_configuration.is_a?( ::CompositingArray ).should == true
71
+ Instance.some_configuration.is_a?( ::Array::Compositing ).should == true
72
72
 
73
73
  RandomInstance = ::Object.new
74
74
  Encapsulation.register_child_for_parent( RandomInstance, Instance )
75
- Encapsulation.get_configuration( RandomInstance, :some_configuration ).is_a?( ::CompositingArray ).should == true
75
+ Encapsulation.get_configuration( RandomInstance, :some_configuration ).is_a?( ::Array::Compositing ).should == true
76
76
 
77
77
  RandomInstance2 = ::Object.new
78
78
  Encapsulation.register_child_for_parent( RandomInstance2, RandomInstance )
79
- Encapsulation.get_configuration( RandomInstance2, :some_configuration ).is_a?( ::CompositingArray ).should == true
79
+ Encapsulation.get_configuration( RandomInstance2, :some_configuration ).is_a?( ::Array::Compositing ).should == true
80
80
 
81
81
  end
82
82
 
@@ -92,7 +92,7 @@ describe ::CascadingConfiguration::Core::Module::ExtendedConfigurations::Composi
92
92
  it 'can set and get values' do
93
93
  module ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects::SetterGetterMock
94
94
 
95
- ClassInstance = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects.new( :setting, ::CompositingArray, :default, '' )
95
+ ClassInstance = ::CascadingConfiguration::Core::Module::ExtendedConfigurations::CompositingObjects.new( :setting, ::Array::Compositing, :default, '' )
96
96
  CCM = ::Module.new do
97
97
  ::CascadingConfiguration::Core.enable( self, ClassInstance )
98
98
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cascading_configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-29 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: module-cluster
@@ -44,7 +44,7 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: accessor-utilities
47
+ name: accessor_utilities
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -60,7 +60,7 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: parallel-ancestry
63
+ name: parallel_ancestry
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
@@ -76,7 +76,7 @@ dependencies:
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: compositing-hash
79
+ name: hash
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
@@ -92,7 +92,7 @@ dependencies:
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  - !ruby/object:Gem::Dependency
95
- name: compositing-array-sorted-unique
95
+ name: array
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
@@ -167,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
168
  - - ! '>='
169
169
  - !ruby/object:Gem::Version
170
- version: '0'
170
+ version: 1.9.1
171
171
  required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  none: false
173
173
  requirements: