module-cluster 1.3.7 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README.md +146 -1
  2. data/README.rdoc +146 -1
  3. data/lib/module-cluster.rb +54 -12
  4. data/lib/module-cluster/ModuleCluster/Define/Block.rb +3 -0
  5. data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +16 -4
  6. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +63 -0
  7. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +2 -0
  8. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +63 -0
  9. data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +32 -0
  10. data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +16 -4
  11. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +63 -0
  12. data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +200 -0
  13. data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +127 -0
  14. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +7 -19
  15. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +5 -20
  16. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +9 -26
  17. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +9 -26
  18. data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +46 -0
  19. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +200 -0
  20. data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +208 -0
  21. data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +127 -0
  22. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +54 -0
  23. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +44 -0
  24. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +209 -0
  25. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack.rb +0 -2
  26. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack/Block.rb +1 -2
  27. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +36 -0
  28. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +20 -0
  29. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +36 -0
  30. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +2 -0
  31. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +108 -0
  32. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +84 -0
  33. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +108 -0
  34. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +84 -0
  35. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +7 -0
  36. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ExtendForCascade.rb +0 -0
  37. data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +230 -0
  38. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +238 -0
  39. data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +231 -0
  40. data/spec/ModuleCluster/Define/Block/Class_spec.rb +224 -0
  41. data/spec/ModuleCluster/Define/Block/Instance_spec.rb +78 -0
  42. data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +54 -0
  43. data/spec/ModuleCluster/Define/Block/Module_spec.rb +224 -0
  44. data/spec/ModuleCluster/Define/Block_spec.rb +18 -0
  45. data/spec/ModuleCluster/Define/ClassCluster_spec.rb +728 -0
  46. data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +576 -0
  47. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +298 -60
  48. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +307 -61
  49. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +335 -36
  50. data/spec/ModuleCluster/Define/Cluster_spec.rb +447 -14
  51. data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +102 -0
  52. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +728 -0
  53. data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +728 -0
  54. data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +576 -0
  55. data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +278 -0
  56. metadata +42 -13
  57. data/lib/module-cluster/ModuleCluster/CascadeFeatures.rb +0 -197
  58. data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
  59. data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
  60. data/lib/module-cluster/ModuleCluster/ClusterStack/Extends.rb +0 -29
  61. data/lib/module-cluster/ModuleCluster/ClusterStack/Includes.rb +0 -28
  62. data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -28
  63. data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -28
  64. data/lib/module-cluster/ModuleCluster/Define/ClusterStack.rb +0 -26
@@ -0,0 +1,84 @@
1
+
2
+ module ModuleCluster::ClusterStack::Includes
3
+
4
+ ###################
5
+ # include_hooks #
6
+ ###################
7
+
8
+ def include_hooks
9
+ return @include_hooks ||= Array.new
10
+ end
11
+
12
+ ######################
13
+ # include_includes #
14
+ ######################
15
+
16
+ def include_includes( module_instance, method, includes, runtime_includes_block )
17
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :include, includes, runtime_includes_block ) )
18
+ end
19
+
20
+ #####################
21
+ # include_extends #
22
+ #####################
23
+
24
+ def include_extends( module_instance, method, extends, runtime_extends_block )
25
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :extend, extends, runtime_extends_block ) )
26
+ end
27
+
28
+ ##################################
29
+ # include_includes_and_extends #
30
+ ##################################
31
+
32
+ def include_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
33
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
34
+ end
35
+
36
+ #############################
37
+ # module_include_includes #
38
+ #############################
39
+
40
+ def module_include_includes( module_instance, method, includes, runtime_includes_block )
41
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :include, includes, runtime_includes_block ) )
42
+ end
43
+
44
+ ############################
45
+ # module_include_extends #
46
+ ############################
47
+
48
+ def module_include_extends( module_instance, method, extends, runtime_extends_block )
49
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :extend, extends, runtime_extends_block ) )
50
+ end
51
+
52
+ #########################################
53
+ # module_include_includes_and_extends #
54
+ #########################################
55
+
56
+ def module_include_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
57
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
58
+ end
59
+
60
+ ############################
61
+ # class_include_includes #
62
+ ############################
63
+
64
+ def class_include_includes( module_instance, method, includes, runtime_includes_block )
65
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :include, includes, runtime_includes_block ) )
66
+ end
67
+
68
+ ###########################
69
+ # class_include_extends #
70
+ ###########################
71
+
72
+ def class_include_extends( module_instance, method, extends, runtime_extends_block )
73
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :extend, extends, runtime_extends_block ) )
74
+ end
75
+
76
+ ########################################
77
+ # class_include_includes_and_extends #
78
+ ########################################
79
+
80
+ def class_include_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
81
+ include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
82
+ end
83
+
84
+ end
@@ -0,0 +1,108 @@
1
+
2
+ module ModuleCluster::ClusterStack::PrependsExtends
3
+
4
+ #############################
5
+ # prepending_extend_hooks #
6
+ #############################
7
+
8
+ def prepending_extend_hooks
9
+ return @prepending_extend_hooks ||= Array.new
10
+ end
11
+
12
+ ##############################
13
+ # extend_prepends_includes #
14
+ ##############################
15
+
16
+ def extend_prepends_includes( module_instance, method, includes, runtime_includes_block )
17
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :include, includes, runtime_includes_block ) )
18
+ end
19
+
20
+ #############################
21
+ # extend_prepends_extends #
22
+ #############################
23
+
24
+ def extend_prepends_extends( module_instance, method, extends, runtime_extends_block )
25
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :extend, extends, runtime_extends_block ) )
26
+ end
27
+
28
+ ##########################################
29
+ # extend_prepends_includes_and_extends #
30
+ ##########################################
31
+
32
+ def extend_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
33
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
34
+ end
35
+
36
+ #####################################
37
+ # module_extend_prepends_includes #
38
+ #####################################
39
+
40
+ def module_extend_prepends_includes( module_instance, method, includes, runtime_includes_block )
41
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :include, includes, runtime_includes_block ) )
42
+ end
43
+
44
+ ####################################
45
+ # module_extend_prepends_extends #
46
+ ####################################
47
+
48
+ def module_extend_prepends_extends( module_instance, method, extends, runtime_extends_block )
49
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :extend, extends, runtime_extends_block ) )
50
+ end
51
+
52
+ #################################################
53
+ # module_extend_prepends_includes_and_extends #
54
+ #################################################
55
+
56
+ def module_extend_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
57
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
58
+ end
59
+
60
+ ####################################
61
+ # class_extend_prepends_includes #
62
+ ####################################
63
+
64
+ def class_extend_prepends_includes( module_instance, method, includes, runtime_includes_block )
65
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :include, includes, runtime_includes_block ) )
66
+ end
67
+
68
+ ###################################
69
+ # class_extend_prepends_extends #
70
+ ###################################
71
+
72
+ def class_extend_prepends_extends( module_instance, method, extends, runtime_extends_block )
73
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :extend, extends, runtime_extends_block ) )
74
+ end
75
+
76
+ ################################################
77
+ # class_extend_prepends_includes_and_extends #
78
+ ################################################
79
+
80
+ def class_extend_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
81
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
82
+ end
83
+
84
+ #######################################
85
+ # instance_extend_prepends_includes #
86
+ #######################################
87
+
88
+ def instance_extend_prepends_includes( module_instance, method, includes, runtime_includes_block )
89
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :instance, :include, includes, runtime_includes_block ) )
90
+ end
91
+
92
+ ######################################
93
+ # instance_extend_prepends_extends #
94
+ ######################################
95
+
96
+ def instance_extend_prepends_extends( module_instance, method, extends, runtime_extends_block )
97
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :instance, :extend, extends, runtime_extends_block ) )
98
+ end
99
+
100
+ ###################################################
101
+ # instance_extend_prepends_includes_and_extends #
102
+ ###################################################
103
+
104
+ def instance_extend_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
105
+ prepending_extend_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :instance, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
106
+ end
107
+
108
+ end
@@ -0,0 +1,84 @@
1
+
2
+ module ModuleCluster::ClusterStack::PrependsIncludes
3
+
4
+ ##############################
5
+ # prepending_include_hooks #
6
+ ##############################
7
+
8
+ def prepending_include_hooks
9
+ return @prepending_include_hooks ||= Array.new
10
+ end
11
+
12
+ ###############################
13
+ # include_prepends_includes #
14
+ ###############################
15
+
16
+ def include_prepends_includes( module_instance, method, includes, runtime_includes_block )
17
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :include, includes, runtime_includes_block ) )
18
+ end
19
+
20
+ ##############################
21
+ # include_prepends_extends #
22
+ ##############################
23
+
24
+ def include_prepends_extends( module_instance, method, extends, runtime_extends_block )
25
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :extend, extends, runtime_extends_block ) )
26
+ end
27
+
28
+ ###########################################
29
+ # include_prepends_includes_and_extends #
30
+ ###########################################
31
+
32
+ def include_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
33
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :all, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
34
+ end
35
+
36
+ ######################################
37
+ # module_include_prepends_includes #
38
+ ######################################
39
+
40
+ def module_include_prepends_includes( module_instance, method, includes, runtime_includes_block )
41
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :include, includes, runtime_includes_block ) )
42
+ end
43
+
44
+ #####################################
45
+ # module_include_prepends_extends #
46
+ #####################################
47
+
48
+ def module_include_prepends_extends( module_instance, method, extends, runtime_extends_block )
49
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :extend, extends, runtime_extends_block ) )
50
+ end
51
+
52
+ ##################################################
53
+ # module_include_prepends_includes_and_extends #
54
+ ##################################################
55
+
56
+ def module_include_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
57
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :module, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
58
+ end
59
+
60
+ #####################################
61
+ # class_include_prepends_includes #
62
+ #####################################
63
+
64
+ def class_include_prepends_includes( module_instance, method, includes, runtime_includes_block )
65
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :include, includes, runtime_includes_block ) )
66
+ end
67
+
68
+ ####################################
69
+ # class_include_prepends_extends #
70
+ ####################################
71
+
72
+ def class_include_prepends_extends( module_instance, method, extends, runtime_extends_block )
73
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :extend, extends, runtime_extends_block ) )
74
+ end
75
+
76
+ #################################################
77
+ # class_include_prepends_includes_and_extends #
78
+ #################################################
79
+
80
+ def class_include_prepends_includes_and_extends( module_instance, method, includes_and_extends, runtime_includes_and_extends_block )
81
+ prepending_include_hooks.push( ModuleCluster::ClusterStack::Set.new( module_instance, method, :class, :include_and_extend, includes_and_extends, runtime_includes_and_extends_block ) )
82
+ end
83
+
84
+ end
@@ -0,0 +1,7 @@
1
+
2
+ ModuleCluster::ClusterStack::Set = Struct.new( :dependency_module,
3
+ :method,
4
+ :module_class_instance_or_all,
5
+ :include_or_extend,
6
+ :modules,
7
+ :runtime_includes_or_extends_block )
@@ -0,0 +1,230 @@
1
+
2
+ require_relative '../../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::Block::ClassOrInstance do
5
+
6
+ ##############################
7
+ # class_or_instance_extend #
8
+ ##############################
9
+
10
+ it 'can run a block on class or instance extend' do
11
+ module ModuleCluster::Define::Block::ClassOrInstance::Mock01
12
+ extend ModuleCluster::Define::Block::ClassOrInstance
13
+ block_ran = false
14
+ class_or_instance_extend do
15
+ block_ran = true
16
+ self.should == ModuleCluster::Define::Block::ClassOrInstance::Mock01
17
+ end
18
+ respond_to?( :extended ).should == true
19
+ module ModuleProof
20
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock01
21
+ end
22
+ block_ran.should == false
23
+ module ModuleProof2
24
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock01
25
+ end
26
+ block_ran.should == false
27
+ class ClassProof
28
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock01
29
+ end
30
+ block_ran.should == false
31
+ class ClassProof2
32
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock01
33
+ end
34
+ block_ran.should == true
35
+ block_ran = false
36
+ Object.new.instance_eval do
37
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock01
38
+ end
39
+ block_ran.should == true
40
+ end
41
+ end
42
+
43
+ ######################################
44
+ # class_include_or_instance_extend #
45
+ ######################################
46
+
47
+ it 'can run a block on class include or instance extend' do
48
+ module ModuleCluster::Define::Block::ClassOrInstance::Mock02
49
+ extend ModuleCluster::Define::Block::ClassOrInstance
50
+ block_ran = false
51
+ class_include_or_instance_extend do
52
+ block_ran = true
53
+ self.should == ModuleCluster::Define::Block::ClassOrInstance::Mock02
54
+ end
55
+ respond_to?( :extended ).should == true
56
+ module ModuleProof
57
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock02
58
+ end
59
+ block_ran.should == false
60
+ module ModuleProof2
61
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock02
62
+ end
63
+ block_ran.should == false
64
+ class ClassProof
65
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock02
66
+ end
67
+ block_ran.should == true
68
+ block_ran = false
69
+ class ClassProof2
70
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock02
71
+ end
72
+ block_ran.should == false
73
+ Object.new.instance_eval do
74
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock02
75
+ end
76
+ block_ran.should == true
77
+ end
78
+ end
79
+
80
+ ################################################
81
+ # class_include_or_extend_or_instance_extend #
82
+ ################################################
83
+
84
+ it 'can run a block on class include or extend or instance extend' do
85
+ module ModuleCluster::Define::Block::ClassOrInstance::Mock03
86
+ extend ModuleCluster::Define::Block::ClassOrInstance
87
+ block_ran = false
88
+ class_include_or_extend_or_instance_extend do
89
+ block_ran = true
90
+ self.should == ModuleCluster::Define::Block::ClassOrInstance::Mock03
91
+ end
92
+ respond_to?( :extended ).should == true
93
+ module ModuleProof
94
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock03
95
+ end
96
+ block_ran.should == false
97
+ module ModuleProof2
98
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock03
99
+ end
100
+ block_ran.should == false
101
+ class ClassProof
102
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock03
103
+ end
104
+ block_ran.should == true
105
+ block_ran = false
106
+ class ClassProof2
107
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock03
108
+ end
109
+ block_ran.should == true
110
+ block_ran = false
111
+ Object.new.instance_eval do
112
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock03
113
+ end
114
+ block_ran.should == true
115
+ end
116
+ end
117
+
118
+ ######################################
119
+ # prepend_class_or_instance_extend #
120
+ ######################################
121
+
122
+ it 'can run a block before class or instance extend' do
123
+ module ModuleCluster::Define::Block::ClassOrInstance::Mock04
124
+ extend ModuleCluster::Define::Block::ClassOrInstance
125
+ block_ran = false
126
+ class_or_instance_extend do
127
+ block_ran = true
128
+ self.should == ModuleCluster::Define::Block::ClassOrInstance::Mock04
129
+ end
130
+ respond_to?( :extended ).should == true
131
+ module ModuleProof
132
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock04
133
+ end
134
+ block_ran.should == false
135
+ module ModuleProof2
136
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock04
137
+ end
138
+ block_ran.should == false
139
+ class ClassProof
140
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock04
141
+ end
142
+ block_ran.should == false
143
+ class ClassProof2
144
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock04
145
+ end
146
+ block_ran.should == true
147
+ block_ran = false
148
+ Object.new.instance_eval do
149
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock04
150
+ end
151
+ block_ran.should == true
152
+ end
153
+ end
154
+
155
+ ##############################################
156
+ # prepend_class_include_or_instance_extend #
157
+ ##############################################
158
+
159
+ it 'can run a block before class include or instance extend' do
160
+ module ModuleCluster::Define::Block::ClassOrInstance::Mock05
161
+ extend ModuleCluster::Define::Block::ClassOrInstance
162
+ block_ran = false
163
+ class_include_or_instance_extend do
164
+ block_ran = true
165
+ self.should == ModuleCluster::Define::Block::ClassOrInstance::Mock05
166
+ end
167
+ respond_to?( :extended ).should == true
168
+ module ModuleProof
169
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock05
170
+ end
171
+ block_ran.should == false
172
+ module ModuleProof2
173
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock05
174
+ end
175
+ block_ran.should == false
176
+ class ClassProof
177
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock05
178
+ end
179
+ block_ran.should == true
180
+ block_ran = false
181
+ class ClassProof2
182
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock05
183
+ end
184
+ block_ran.should == false
185
+ Object.new.instance_eval do
186
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock05
187
+ end
188
+ block_ran.should == true
189
+ end
190
+ end
191
+
192
+ ########################################################
193
+ # prepend_class_include_or_extend_or_instance_extend #
194
+ ########################################################
195
+
196
+ it 'can run a block before class include or extend or instance extend' do
197
+ module ModuleCluster::Define::Block::ClassOrInstance::Mock06
198
+ extend ModuleCluster::Define::Block::ClassOrInstance
199
+ block_ran = false
200
+ class_include_or_extend_or_instance_extend do
201
+ block_ran = true
202
+ self.should == ModuleCluster::Define::Block::ClassOrInstance::Mock06
203
+ end
204
+ respond_to?( :extended ).should == true
205
+ module ModuleProof
206
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock06
207
+ end
208
+ block_ran.should == false
209
+ module ModuleProof2
210
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock06
211
+ end
212
+ block_ran.should == false
213
+ class ClassProof
214
+ include ModuleCluster::Define::Block::ClassOrInstance::Mock06
215
+ end
216
+ block_ran.should == true
217
+ block_ran = false
218
+ class ClassProof2
219
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock06
220
+ end
221
+ block_ran.should == true
222
+ block_ran = false
223
+ Object.new.instance_eval do
224
+ extend ModuleCluster::Define::Block::ClassOrInstance::Mock06
225
+ end
226
+ block_ran.should == true
227
+ end
228
+ end
229
+
230
+ end