module-cluster 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. data/lib/module-cluster.rb +17 -13
  2. data/lib/module-cluster/ModuleCluster.rb +8 -8
  3. data/lib/module-cluster/ModuleCluster/CascadeFeatures.rb +155 -0
  4. data/lib/module-cluster/ModuleCluster/ClusterStack.rb +102 -0
  5. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +203 -0
  6. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +220 -0
  7. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +209 -0
  8. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +209 -0
  9. data/lib/module-cluster/ModuleCluster/Define/ClusterStack.rb +26 -0
  10. data/lib/module-cluster/ModuleCluster/Define/DedoubleAncestors.rb +22 -0
  11. data/lib/module-cluster/ModuleCluster/ExtendForCascade.rb +15 -0
  12. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +421 -0
  13. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +432 -0
  14. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +345 -0
  15. data/spec/ModuleCluster/Define/Cluster_spec.rb +275 -0
  16. data/spec/ModuleCluster_spec.rb +4 -4
  17. metadata +16 -14
  18. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +0 -211
  19. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascades.rb +0 -223
  20. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToClass.rb +0 -223
  21. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToModule.rb +0 -227
  22. data/lib/module-cluster/ModuleCluster/Define/_private_/AnonymousModule.rb +0 -121
  23. data/lib/module-cluster/ModuleCluster/Define/_private_/ClusterStack.rb +0 -55
  24. data/spec/ModuleCluster/Define/ModuleClusterCascadesToClass_spec.rb +0 -421
  25. data/spec/ModuleCluster/Define/ModuleClusterCascadesToModule_spec.rb +0 -432
  26. data/spec/ModuleCluster/Define/ModuleClusterCascades_spec.rb +0 -345
  27. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +0 -275
  28. data/spec/ModuleCluster/Define/_private_/ClusterStack_spec.rb +0 -24
@@ -0,0 +1,275 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::Cluster do
5
+
6
+ ###########################
7
+ # include_also_includes #
8
+ ###########################
9
+
10
+ it 'include other modules when this one is included' do
11
+ module ModuleCluster::Define::Cluster::Mock01
12
+ extend ModuleCluster::Define::Cluster
13
+ module Module1
14
+ end
15
+ module Module2
16
+ end
17
+ include_also_includes( Module1, Module2 )
18
+ respond_to?( :included ).should == true
19
+ module Proof
20
+ include ModuleCluster::Define::Cluster::Mock01
21
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock01::Module1 ).should == true
22
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock01::Module2 ).should == true
23
+ end
24
+ end
25
+ end
26
+
27
+ ##########################
28
+ # include_also_extends #
29
+ ##########################
30
+
31
+ it 'extend other modules when this one is included' do
32
+ module ModuleCluster::Define::Cluster::Mock02
33
+ extend ModuleCluster::Define::Cluster
34
+ module Module1
35
+ end
36
+ module Module2
37
+ end
38
+ include_also_extends( Module1, Module2 )
39
+ respond_to?( :included ).should == true
40
+ module Proof
41
+ include ModuleCluster::Define::Cluster::Mock02
42
+ eigenclass = class << self ; self ; end
43
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock02::Module1 ).should == true
44
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock02::Module2 ).should == true
45
+ end
46
+ end
47
+ end
48
+
49
+ #######################################
50
+ # include_also_includes_and_extends #
51
+ #######################################
52
+
53
+ it 'include and extend other modules when this one is included' do
54
+ module ModuleCluster::Define::Cluster::Mock03
55
+ extend ModuleCluster::Define::Cluster
56
+ module Module1
57
+ end
58
+ module Module2
59
+ end
60
+ include_also_includes_and_extends( Module1, Module2 )
61
+ respond_to?( :included ).should == true
62
+ module Proof
63
+ include ModuleCluster::Define::Cluster::Mock03
64
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock03::Module1 ).should == true
65
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock03::Module2 ).should == true
66
+ eigenclass = class << self ; self ; end
67
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock03::Module1 ).should == true
68
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock03::Module2 ).should == true
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ ##########################
75
+ # extend_also_includes #
76
+ ##########################
77
+
78
+ it 'include other modules when this one is extended' do
79
+ module ModuleCluster::Define::Cluster::Mock04
80
+ extend ModuleCluster::Define::Cluster
81
+ module Module1
82
+ end
83
+ module Module2
84
+ end
85
+ extend_also_includes( Module1, Module2 )
86
+ respond_to?( :extended ).should == true
87
+ module Proof
88
+ extend ModuleCluster::Define::Cluster::Mock04
89
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock04::Module1 ).should == true
90
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock04::Module2 ).should == true
91
+ end
92
+ end
93
+ end
94
+
95
+ #########################
96
+ # extend_also_extends #
97
+ #########################
98
+
99
+ it 'extend other modules when this one is extended' do
100
+ module ModuleCluster::Define::Cluster::Mock05
101
+ extend ModuleCluster::Define::Cluster
102
+ module Module1
103
+ end
104
+ module Module2
105
+ end
106
+ extend_also_extends( Module1, Module2 )
107
+ respond_to?( :extended ).should == true
108
+ module Proof
109
+ extend ModuleCluster::Define::Cluster::Mock05
110
+ eigenclass = class << self ; self ; end
111
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock05::Module1 ).should == true
112
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock05::Module2 ).should == true
113
+ end
114
+ end
115
+ end
116
+
117
+ ######################################
118
+ # extend_also_includes_and_extends #
119
+ ######################################
120
+
121
+ it 'include and extend other modules when this one is extended' do
122
+ module ModuleCluster::Define::Cluster::Mock06
123
+ extend ModuleCluster::Define::Cluster
124
+ module Module1
125
+ end
126
+ module Module2
127
+ end
128
+ extend_also_includes_and_extends( Module1, Module2 )
129
+ respond_to?( :extended ).should == true
130
+ module Proof
131
+ extend ModuleCluster::Define::Cluster::Mock06
132
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock06::Module1 ).should == true
133
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock06::Module2 ).should == true
134
+ eigenclass = class << self ; self ; end
135
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock06::Module1 ).should == true
136
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock06::Module2 ).should == true
137
+ end
138
+ end
139
+ end
140
+
141
+ ###############################
142
+ # include_prepends_includes #
143
+ ###############################
144
+
145
+ it 'include other modules before this one is included' do
146
+ module ModuleCluster::Define::Cluster::Mock07
147
+ extend ModuleCluster::Define::Cluster
148
+ module Module1
149
+ end
150
+ module Module2
151
+ end
152
+ include_prepends_includes( Module1, Module2 )
153
+ respond_to?( :append_features ).should == true
154
+ module Proof
155
+ include ModuleCluster::Define::Cluster::Mock07
156
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock07::Module1 ).should == true
157
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock07::Module2 ).should == true
158
+ end
159
+ end
160
+ end
161
+
162
+ ##############################
163
+ # include_prepends_extends #
164
+ ##############################
165
+
166
+ it 'extend other modules before this one is included' do
167
+ module ModuleCluster::Define::Cluster::Mock08
168
+ extend ModuleCluster::Define::Cluster
169
+ module Module1
170
+ end
171
+ module Module2
172
+ end
173
+ include_prepends_extends( Module1, Module2 )
174
+ respond_to?( :append_features ).should == true
175
+ module Proof
176
+ include ModuleCluster::Define::Cluster::Mock08
177
+ eigenclass = class << self ; self ; end
178
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock08::Module1 ).should == true
179
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock08::Module2 ).should == true
180
+ end
181
+ end
182
+ end
183
+
184
+ ###########################################
185
+ # include_prepends_includes_and_extends #
186
+ ###########################################
187
+
188
+ it 'include and extend other modules before this one is included' do
189
+ module ModuleCluster::Define::Cluster::Mock09
190
+ extend ModuleCluster::Define::Cluster
191
+ module Module1
192
+ end
193
+ module Module2
194
+ end
195
+ include_prepends_includes_and_extends( Module1, Module2 )
196
+ respond_to?( :append_features ).should == true
197
+ module Proof
198
+ include ModuleCluster::Define::Cluster::Mock09
199
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock09::Module1 ).should == true
200
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock09::Module2 ).should == true
201
+ eigenclass = class << self ; self ; end
202
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock09::Module1 ).should == true
203
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock09::Module2 ).should == true
204
+ end
205
+ end
206
+ end
207
+
208
+ ##############################
209
+ # extend_prepends_includes #
210
+ ##############################
211
+
212
+ it 'include other modules before this one is extended' do
213
+ module ModuleCluster::Define::Cluster::Mock10
214
+ extend ModuleCluster::Define::Cluster
215
+ module Module1
216
+ end
217
+ module Module2
218
+ end
219
+ extend_prepends_includes( Module1, Module2 )
220
+ respond_to?( :extend_object ).should == true
221
+ module Proof
222
+ extend ModuleCluster::Define::Cluster::Mock10
223
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock10::Module1 ).should == true
224
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock10::Module2 ).should == true
225
+ end
226
+ end
227
+ end
228
+
229
+ #############################
230
+ # extend_prepends_extends #
231
+ #############################
232
+
233
+ it 'extend other modules before this one is extended' do
234
+ module ModuleCluster::Define::Cluster::Mock11
235
+ extend ModuleCluster::Define::Cluster
236
+ module Module1
237
+ end
238
+ module Module2
239
+ end
240
+ extend_prepends_extends( Module1, Module2 )
241
+ respond_to?( :extend_object ).should == true
242
+ module Proof
243
+ extend ModuleCluster::Define::Cluster::Mock11
244
+ eigenclass = class << self ; self ; end
245
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock11::Module1 ).should == true
246
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock11::Module2 ).should == true
247
+ end
248
+ end
249
+ end
250
+
251
+ ##########################################
252
+ # extend_prepends_includes_and_extends #
253
+ ##########################################
254
+
255
+ it 'include and extend other modules before this one is extended' do
256
+ module ModuleCluster::Define::Cluster::Mock12
257
+ extend ModuleCluster::Define::Cluster
258
+ module Module1
259
+ end
260
+ module Module2
261
+ end
262
+ extend_prepends_includes_and_extends( Module1, Module2 )
263
+ respond_to?( :extend_object ).should == true
264
+ module Proof
265
+ extend ModuleCluster::Define::Cluster::Mock12
266
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock12::Module1 ).should == true
267
+ ancestors.include?( ModuleCluster::Define::Cluster::Mock12::Module2 ).should == true
268
+ eigenclass = class << self ; self ; end
269
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock12::Module1 ).should == true
270
+ eigenclass.ancestors.include?( ModuleCluster::Define::Cluster::Mock12::Module2 ).should == true
271
+ end
272
+ end
273
+ end
274
+
275
+ end
@@ -4,10 +4,10 @@ describe ModuleCluster do
4
4
 
5
5
  it 'clusters other modules' do
6
6
  module ModuleCluster
7
- is_a?( ModuleCluster::Define::ModuleCluster )
8
- is_a?( ModuleCluster::Define::ModuleClusterCascades )
9
- is_a?( ModuleCluster::Define::ModuleClusterCascadesToClass )
10
- is_a?( ModuleCluster::Define::ModuleClusterCascadesToModule )
7
+ is_a?( ModuleCluster::Define::Cluster )
8
+ is_a?( ModuleCluster::Define::ClusterCascades )
9
+ is_a?( ModuleCluster::Define::ClusterCascadesToClass )
10
+ is_a?( ModuleCluster::Define::ClusterCascadesToModule )
11
11
  is_a?( ModuleCluster::Define::Deprecated )
12
12
  end
13
13
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 3
8
- - 1
9
- version: 1.3.1
8
+ - 2
9
+ version: 1.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Asher
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-08-04 00:00:00 -04:00
17
+ date: 2011-08-06 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -27,20 +27,22 @@ extensions: []
27
27
  extra_rdoc_files: []
28
28
 
29
29
  files:
30
- - lib/module-cluster/ModuleCluster/Define/_private_/AnonymousModule.rb
31
- - lib/module-cluster/ModuleCluster/Define/_private_/ClusterStack.rb
30
+ - lib/module-cluster/ModuleCluster/CascadeFeatures.rb
31
+ - lib/module-cluster/ModuleCluster/ClusterStack.rb
32
+ - lib/module-cluster/ModuleCluster/Define/Cluster.rb
33
+ - lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb
34
+ - lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb
35
+ - lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb
36
+ - lib/module-cluster/ModuleCluster/Define/ClusterStack.rb
37
+ - lib/module-cluster/ModuleCluster/Define/DedoubleAncestors.rb
32
38
  - lib/module-cluster/ModuleCluster/Define/Deprecated.rb
33
- - lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb
34
- - lib/module-cluster/ModuleCluster/Define/ModuleClusterCascades.rb
35
- - lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToClass.rb
36
- - lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToModule.rb
39
+ - lib/module-cluster/ModuleCluster/ExtendForCascade.rb
37
40
  - lib/module-cluster/ModuleCluster.rb
38
41
  - lib/module-cluster.rb
39
- - spec/ModuleCluster/Define/_private_/ClusterStack_spec.rb
40
- - spec/ModuleCluster/Define/ModuleCluster_spec.rb
41
- - spec/ModuleCluster/Define/ModuleClusterCascades_spec.rb
42
- - spec/ModuleCluster/Define/ModuleClusterCascadesToClass_spec.rb
43
- - spec/ModuleCluster/Define/ModuleClusterCascadesToModule_spec.rb
42
+ - spec/ModuleCluster/Define/Cluster_spec.rb
43
+ - spec/ModuleCluster/Define/ClusterCascades_spec.rb
44
+ - spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb
45
+ - spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb
44
46
  - spec/ModuleCluster_spec.rb
45
47
  - README.md
46
48
  - README.rdoc
@@ -1,211 +0,0 @@
1
-
2
- module ModuleCluster::Define::ModuleCluster
3
-
4
- include ModuleCluster::Define::AnonymousModule
5
-
6
- ########################
7
- # self.include_block #
8
- ########################
9
-
10
- def self.include_block( *includes )
11
- return Proc.new do
12
- unless ( includes -= ancestors ).empty?
13
- include( *includes.reverse )
14
- end
15
- end
16
- end
17
-
18
- #######################
19
- # self.extend_block #
20
- #######################
21
-
22
- def self.extend_block( *extends )
23
- return Proc.new do
24
- eigenclass = class << self ; self ; end
25
- unless ( extends -= eigenclass.ancestors ).empty?
26
- extend( *extends.reverse )
27
- end
28
- end
29
- end
30
-
31
- ###########################
32
- # include_also_includes #
33
- ###########################
34
-
35
- def include_also_includes( *includes )
36
- includes_module = anonymous_module_for_included( & ModuleCluster::Define::ModuleCluster.include_block( *includes ) )
37
- clusterstack_module { include( includes_module ) }
38
- return self
39
- end
40
-
41
- ##########################
42
- # include_also_extends #
43
- ##########################
44
-
45
- def include_also_extends( *extends )
46
- extends_module = anonymous_module_for_included( & ModuleCluster::Define::ModuleCluster.extend_block( *extends ) )
47
- clusterstack_module { include( extends_module ) }
48
- return self
49
- end
50
-
51
- #######################################
52
- # include_also_includes_and_extends #
53
- #######################################
54
-
55
- def include_also_includes_and_extends( *includes_and_extends )
56
- include_also_includes( *includes_and_extends )
57
- include_also_extends( *includes_and_extends )
58
- return self
59
- end
60
-
61
- ##########################
62
- # extend_also_includes #
63
- ##########################
64
-
65
- def extend_also_includes( *includes )
66
- includes_module = anonymous_module_for_extended( & ModuleCluster::Define::ModuleCluster.include_block( *includes ) )
67
- clusterstack_module { include( includes_module ) }
68
- return self
69
- end
70
-
71
- #########################
72
- # extend_also_extends #
73
- #########################
74
-
75
- def extend_also_extends( *extends )
76
- extends_module = anonymous_module_for_extended( & ModuleCluster::Define::ModuleCluster.extend_block( *extends ) )
77
- clusterstack_module { include( extends_module ) }
78
- return self
79
- end
80
-
81
- ######################################
82
- # extend_also_includes_and_extends #
83
- ######################################
84
-
85
- def extend_also_includes_and_extends( *includes_and_extends )
86
- extend_also_includes( *includes_and_extends )
87
- extend_also_extends( *includes_and_extends )
88
- return self
89
- end
90
-
91
- ###############################
92
- # include_prepends_includes #
93
- ###############################
94
-
95
- def include_prepends_includes( *includes )
96
- includes_module = anonymous_module_for_append_features( & ModuleCluster::Define::ModuleCluster.include_block( *includes ) )
97
- clusterstack_module { include( includes_module ) }
98
- return self
99
- end
100
-
101
- ##############################
102
- # include_prepends_extends #
103
- ##############################
104
-
105
- def include_prepends_extends( *extends )
106
- extends_module = anonymous_module_for_append_features( & ModuleCluster::Define::ModuleCluster.extend_block( *extends ) )
107
- clusterstack_module { include( extends_module ) }
108
- return self
109
- end
110
-
111
- ###########################################
112
- # include_prepends_includes_and_extends #
113
- ###########################################
114
-
115
- def include_prepends_includes_and_extends( *includes_and_extends )
116
- include_prepends_includes( *includes_and_extends )
117
- include_prepends_extends( *includes_and_extends )
118
- return self
119
- end
120
-
121
- ##############################
122
- # extend_prepends_includes #
123
- ##############################
124
-
125
- def extend_prepends_includes( *includes )
126
- includes_module = anonymous_module_for_extend_object( & ModuleCluster::Define::ModuleCluster.include_block( *includes ) )
127
- clusterstack_module { include( includes_module ) }
128
- return self
129
- end
130
-
131
- #############################
132
- # extend_prepends_extends #
133
- #############################
134
-
135
- def extend_prepends_extends( *extends )
136
- extends_module = anonymous_module_for_extend_object( & ModuleCluster::Define::ModuleCluster.extend_block( *extends ) )
137
- clusterstack_module { include( extends_module ) }
138
- return self
139
- end
140
-
141
- ##########################################
142
- # extend_prepends_includes_and_extends #
143
- ##########################################
144
-
145
- def extend_prepends_includes_and_extends( *includes_and_extends )
146
- extend_prepends_includes( *includes_and_extends )
147
- extend_prepends_extends( *includes_and_extends )
148
- return self
149
- end
150
-
151
- #####################################
152
- # include_or_extend_also_includes #
153
- #####################################
154
-
155
- def include_or_extend_also_includes( *includes )
156
- include_also_includes( *includes )
157
- extend_also_includes( *includes )
158
- return self
159
- end
160
-
161
- ####################################
162
- # include_or_extend_also_extends #
163
- ####################################
164
-
165
- def include_or_extend_also_extends( *extends )
166
- include_also_extends( *extends )
167
- extend_also_extends( *extends )
168
- return self
169
- end
170
-
171
- #################################################
172
- # include_or_extend_also_includes_and_extends #
173
- #################################################
174
-
175
- def include_or_extend_also_includes_and_extends( *includes_and_extends )
176
- include_prepends_includes_and_extends( *includes_and_extends )
177
- extend_prepends_includes_and_extends( *includes_and_extends )
178
- return self
179
- end
180
-
181
- #########################################
182
- # include_or_extend_prepends_includes #
183
- #########################################
184
-
185
- def include_or_extend_prepends_includes( *includes )
186
- include_prepends_includes( *includes )
187
- extend_prepends_includes( *includes )
188
- return self
189
- end
190
-
191
- ########################################
192
- # include_or_extend_prepends_extends #
193
- ########################################
194
-
195
- def include_or_extend_prepends_extends( *extends )
196
- include_prepends_extends( *extends )
197
- extend_prepends_extends( *extends )
198
- return self
199
- end
200
-
201
- #####################################################
202
- # include_or_extend_prepends_includes_and_extends #
203
- #####################################################
204
-
205
- def include_or_extend_prepends_includes_and_extends( *includes_and_extends )
206
- include_prepends_includes_and_extends( *includes_and_extends )
207
- extend_prepends_includes_and_extends( *includes_and_extends )
208
- return self
209
- end
210
-
211
- end