module-cluster 1.4.8 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README.md +127 -337
  2. data/lib/module-cluster.rb +1 -153
  3. data/lib/module/cluster.rb +341 -0
  4. data/lib/module/cluster/class_support.rb +22 -0
  5. data/lib/module/cluster/cluster.rb +10 -0
  6. data/lib/module/cluster/cluster/cluster_interface.rb +550 -0
  7. data/lib/module/cluster/exception/module_not_in_stack.rb +26 -0
  8. data/lib/module/cluster/instance_controller.rb +14 -0
  9. data/lib/module/cluster/instance_controller/hook_controller.rb +33 -0
  10. data/lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb +511 -0
  11. data/lib/module/cluster/instance_controller/hook_controller/hook_controller_interface.rb +830 -0
  12. data/lib/module/cluster/instance_controller/instance_controller_interface.rb +269 -0
  13. data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy.rb +359 -0
  14. data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy/chain_proxy.rb +442 -0
  15. data/lib/module/cluster/module_support.rb +67 -0
  16. data/lib/module/namespaces.rb +13 -0
  17. data/lib/module/requires.rb +32 -0
  18. data/spec/module/cluster/cluster_spec.rb +473 -0
  19. data/spec/module/cluster/instance_controller/hook_controller_spec.rb +922 -0
  20. data/spec/module/cluster/instance_controller/multiple_hook_controller_proxy_spec.rb +1240 -0
  21. data/spec/module/cluster_spec.rb +1794 -0
  22. metadata +27 -98
  23. data/README.rdoc +0 -395
  24. data/lib/module-cluster/ModuleCluster.rb +0 -9
  25. data/lib/module-cluster/ModuleCluster/Define.rb +0 -12
  26. data/lib/module-cluster/ModuleCluster/Define/Block.rb +0 -9
  27. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClass.rb +0 -83
  28. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClassOrModule.rb +0 -70
  29. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModule.rb +0 -79
  30. data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModuleOrSubclass.rb +0 -21
  31. data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +0 -77
  32. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +0 -78
  33. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +0 -78
  34. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +0 -78
  35. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrSubclass.rb +0 -36
  36. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrSubclass.rb +0 -29
  37. data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +0 -45
  38. data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +0 -77
  39. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +0 -78
  40. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrSubclass.rb +0 -29
  41. data/lib/module-cluster/ModuleCluster/Define/Block/Subclass.rb +0 -56
  42. data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +0 -193
  43. data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +0 -128
  44. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +0 -181
  45. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +0 -185
  46. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +0 -181
  47. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +0 -181
  48. data/lib/module-cluster/ModuleCluster/Define/Deprecated.rb +0 -40
  49. data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +0 -45
  50. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +0 -193
  51. data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +0 -209
  52. data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +0 -128
  53. data/lib/module-cluster/ModuleCluster/Define/Status.rb +0 -106
  54. data/lib/module-cluster/ModuleCluster/Suspend.rb +0 -7
  55. data/lib/module-cluster/ModuleCluster/Suspend/Hooks.rb +0 -315
  56. data/lib/module-cluster/ModuleCluster/Suspend/WithoutHooks.rb +0 -153
  57. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +0 -77
  58. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +0 -44
  59. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +0 -292
  60. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/Subclass.rb +0 -24
  61. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack.rb +0 -12
  62. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block.rb +0 -9
  63. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
  64. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Inherited.rb +0 -20
  65. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +0 -20
  66. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
  67. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +0 -6
  68. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +0 -140
  69. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +0 -110
  70. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -140
  71. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -110
  72. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +0 -35
  73. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy.rb +0 -359
  74. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Status.rb +0 -55
  75. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Suspend.rb +0 -199
  76. data/lib/module-cluster/_private_/ModuleCluster/ExtendForCascade.rb +0 -34
  77. data/spec/ModuleCluster/Define/Block/CascadingClassOrModule_spec.rb +0 -285
  78. data/spec/ModuleCluster/Define/Block/CascadingClass_spec.rb +0 -254
  79. data/spec/ModuleCluster/Define/Block/CascadingModuleOrSubclass_spec.rb +0 -56
  80. data/spec/ModuleCluster/Define/Block/CascadingModule_spec.rb +0 -278
  81. data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +0 -230
  82. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +0 -238
  83. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrSubclass_spec.rb +0 -54
  84. data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +0 -231
  85. data/spec/ModuleCluster/Define/Block/ClassOrSubclass_spec.rb +0 -54
  86. data/spec/ModuleCluster/Define/Block/Class_spec.rb +0 -224
  87. data/spec/ModuleCluster/Define/Block/Instance_spec.rb +0 -78
  88. data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +0 -54
  89. data/spec/ModuleCluster/Define/Block/ModuleOrSubclass_spec.rb +0 -51
  90. data/spec/ModuleCluster/Define/Block/Module_spec.rb +0 -230
  91. data/spec/ModuleCluster/Define/Block/Subclass_spec.rb +0 -73
  92. data/spec/ModuleCluster/Define/Block_spec.rb +0 -18
  93. data/spec/ModuleCluster/Define/ClassCluster_spec.rb +0 -728
  94. data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +0 -576
  95. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +0 -659
  96. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +0 -678
  97. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +0 -644
  98. data/spec/ModuleCluster/Define/Cluster_spec.rb +0 -708
  99. data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +0 -102
  100. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +0 -728
  101. data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +0 -728
  102. data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +0 -576
  103. data/spec/ModuleCluster/Suspend/Hooks_spec.rb +0 -573
  104. data/spec/ModuleCluster/Suspend/WithoutHooks_spec.rb +0 -559
  105. data/spec/ModuleCluster_spec.rb +0 -15
  106. data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +0 -386
  107. data/spec/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy_spec.rb +0 -419
  108. data/spec/_private_/ModuleCluster/ClusterStack/Suspend_spec.rb +0 -242
@@ -1,242 +0,0 @@
1
-
2
- require_relative '../../../../lib/module-cluster.rb'
3
-
4
- describe ::ModuleCluster::ClusterStack::Suspend do
5
-
6
- ##########################
7
- # suspend_any_hooks #
8
- # all_hooks_suspended? #
9
- # resume_any_hooks #
10
- ##########################
11
-
12
- it 'can suspend all hooks at once' do
13
- class ::ModuleCluster::ClusterStack::Suspend::Mock01
14
- include ::ModuleCluster::ClusterStack::Suspend
15
- end
16
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock01.new
17
- instance.all_hooks_suspended?.should == false
18
- instance.suspend_any_hooks
19
- instance.all_hooks_suspended?.should == true
20
- instance.all_include_hooks_suspended?.should == true
21
- instance.all_extend_hooks_suspended?.should == true
22
- instance.include_hooks_suspended?.should == true
23
- instance.extend_hooks_suspended?.should == true
24
- instance.prepend_include_hooks_suspended?.should == true
25
- instance.prepend_extend_hooks_suspended?.should == true
26
- instance.resume_any_hooks
27
- instance.all_hooks_suspended?.should == false
28
- end
29
-
30
- ##################################
31
- # suspend_any_include_hooks #
32
- # all_include_hooks_suspended? #
33
- # resume_any_include_hooks #
34
- ##################################
35
-
36
- it 'can suspend all include hooks at once' do
37
- class ::ModuleCluster::ClusterStack::Suspend::Mock02
38
- include ::ModuleCluster::ClusterStack::Suspend
39
- end
40
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock02.new
41
- instance.all_include_hooks_suspended?.should == false
42
- instance.suspend_any_include_hooks
43
- instance.all_include_hooks_suspended?.should == true
44
- instance.include_hooks_suspended?.should == true
45
- instance.prepend_include_hooks_suspended?.should == true
46
- instance.all_hooks_suspended?.should == false
47
- instance.all_extend_hooks_suspended?.should == false
48
- instance.resume_any_include_hooks
49
- instance.all_include_hooks_suspended?.should == false
50
- end
51
-
52
- #################################
53
- # suspend_any_extend_hooks #
54
- # all_extend_hooks_suspended? #
55
- # resume_any_extend_hooks #
56
- #################################
57
-
58
- it 'can suspend all extend hooks at once' do
59
- class ::ModuleCluster::ClusterStack::Suspend::Mock03
60
- include ::ModuleCluster::ClusterStack::Suspend
61
- end
62
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock03.new
63
- instance.all_extend_hooks_suspended?.should == false
64
- instance.suspend_any_extend_hooks
65
- instance.all_extend_hooks_suspended?.should == true
66
- instance.extend_hooks_suspended?.should == true
67
- instance.prepend_extend_hooks_suspended?.should == true
68
- instance.all_hooks_suspended?.should == false
69
- instance.all_include_hooks_suspended?.should == false
70
- instance.resume_any_extend_hooks
71
- instance.all_extend_hooks_suspended?.should == false
72
- end
73
-
74
- ##############################
75
- # suspend_include_hooks #
76
- # include_hooks_suspended? #
77
- # resume_include_hooks #
78
- ##############################
79
-
80
- it 'can suspend all include hooks' do
81
- class ::ModuleCluster::ClusterStack::Suspend::Mock04
82
- include ::ModuleCluster::ClusterStack::Suspend
83
- end
84
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock04.new
85
- instance.include_hooks_suspended?.should == false
86
- instance.suspend_include_hooks
87
- instance.include_hooks_suspended?.should == true
88
- instance.all_hooks_suspended?.should == false
89
- instance.all_include_hooks_suspended?.should == false
90
- instance.all_extend_hooks_suspended?.should == false
91
- instance.extend_hooks_suspended?.should == false
92
- instance.prepend_include_hooks_suspended?.should == false
93
- instance.prepend_extend_hooks_suspended?.should == false
94
- instance.resume_include_hooks
95
- instance.include_hooks_suspended?.should == false
96
- end
97
-
98
- #############################
99
- # suspend_extend_hooks #
100
- # extend_hooks_suspended? #
101
- # resume_extend_hooks #
102
- #############################
103
-
104
- it 'can suspend all extend hooks' do
105
- class ::ModuleCluster::ClusterStack::Suspend::Mock05
106
- include ::ModuleCluster::ClusterStack::Suspend
107
- end
108
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock05.new
109
- instance.extend_hooks_suspended?.should == false
110
- instance.suspend_extend_hooks
111
- instance.extend_hooks_suspended?.should == true
112
- instance.all_hooks_suspended?.should == false
113
- instance.all_include_hooks_suspended?.should == false
114
- instance.all_extend_hooks_suspended?.should == false
115
- instance.include_hooks_suspended?.should == false
116
- instance.prepend_include_hooks_suspended?.should == false
117
- instance.prepend_extend_hooks_suspended?.should == false
118
- instance.resume_extend_hooks
119
- instance.extend_hooks_suspended?.should == false
120
- end
121
-
122
- ######################################
123
- # suspend_prepend_include_hooks #
124
- # prepend_include_hooks_suspended? #
125
- # resume_prepend_include_hooks #
126
- ######################################
127
-
128
- it 'can suspend all prepend include hooks' do
129
- class ::ModuleCluster::ClusterStack::Suspend::Mock06
130
- include ::ModuleCluster::ClusterStack::Suspend
131
- end
132
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock06.new
133
- instance.prepend_include_hooks_suspended?.should == false
134
- instance.suspend_prepend_include_hooks
135
- instance.prepend_include_hooks_suspended?.should == true
136
- instance.all_hooks_suspended?.should == false
137
- instance.all_include_hooks_suspended?.should == false
138
- instance.all_extend_hooks_suspended?.should == false
139
- instance.include_hooks_suspended?.should == false
140
- instance.extend_hooks_suspended?.should == false
141
- instance.prepend_extend_hooks_suspended?.should == false
142
- instance.resume_prepend_include_hooks
143
- instance.prepend_include_hooks_suspended?.should == false
144
- end
145
-
146
- #####################################
147
- # suspend_prepend_extend_hooks #
148
- # prepend_extend_hooks_suspended? #
149
- # resume_prepend_extend_hooks #
150
- #####################################
151
-
152
- it 'can suspend all prepend extend hooks' do
153
- class ::ModuleCluster::ClusterStack::Suspend::Mock07
154
- include ::ModuleCluster::ClusterStack::Suspend
155
- end
156
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock07.new
157
- instance.prepend_extend_hooks_suspended?.should == false
158
- instance.suspend_prepend_extend_hooks
159
- instance.prepend_extend_hooks_suspended?.should == true
160
- instance.all_hooks_suspended?.should == false
161
- instance.all_include_hooks_suspended?.should == false
162
- instance.all_extend_hooks_suspended?.should == false
163
- instance.include_hooks_suspended?.should == false
164
- instance.extend_hooks_suspended?.should == false
165
- instance.prepend_include_hooks_suspended?.should == false
166
- instance.resume_prepend_extend_hooks
167
- instance.prepend_extend_hooks_suspended?.should == false
168
- end
169
-
170
- ######################
171
- # hooks_suspended? #
172
- ######################
173
-
174
- it 'can report whether hooks are extended for all of current action' do
175
- class ::ModuleCluster::ClusterStack::Suspend::Mock08
176
- include ::ModuleCluster::ClusterStack::Suspend
177
- end
178
- instance = ::ModuleCluster::ClusterStack::Suspend::Mock08.new
179
- instance.hooks_suspended?( :prepend_include ).should == false
180
- instance.hooks_suspended?( :include ).should == false
181
- instance.hooks_suspended?( :prepend_extend ).should == false
182
- instance.hooks_suspended?( :extend ).should == false
183
-
184
- # suspend all
185
- instance.suspend_any_hooks
186
- instance.hooks_suspended?( :prepend_include ).should == true
187
- instance.hooks_suspended?( :include ).should == true
188
- instance.hooks_suspended?( :prepend_extend ).should == true
189
- instance.hooks_suspended?( :extend ).should == true
190
- instance.resume_any_hooks
191
-
192
- # suspend all include
193
- instance.suspend_any_include_hooks
194
- instance.hooks_suspended?( :prepend_include ).should == true
195
- instance.hooks_suspended?( :include ).should == true
196
- instance.hooks_suspended?( :prepend_extend ).should == false
197
- instance.hooks_suspended?( :extend ).should == false
198
- instance.resume_any_include_hooks
199
-
200
- # suspend all extend
201
- instance.suspend_any_extend_hooks
202
- instance.hooks_suspended?( :prepend_include ).should == false
203
- instance.hooks_suspended?( :include ).should == false
204
- instance.hooks_suspended?( :prepend_extend ).should == true
205
- instance.hooks_suspended?( :extend ).should == true
206
- instance.resume_any_extend_hooks
207
-
208
- # suspend prepend include
209
- instance.suspend_prepend_include_hooks
210
- instance.hooks_suspended?( :prepend_include ).should == true
211
- instance.hooks_suspended?( :include ).should == false
212
- instance.hooks_suspended?( :prepend_extend ).should == false
213
- instance.hooks_suspended?( :extend ).should == false
214
- instance.resume_prepend_include_hooks
215
-
216
- # suspend include
217
- instance.suspend_include_hooks
218
- instance.hooks_suspended?( :prepend_include ).should == false
219
- instance.hooks_suspended?( :include ).should == true
220
- instance.hooks_suspended?( :prepend_extend ).should == false
221
- instance.hooks_suspended?( :extend ).should == false
222
- instance.resume_include_hooks
223
-
224
- # suspend prepend extend
225
- instance.suspend_prepend_extend_hooks
226
- instance.hooks_suspended?( :prepend_include ).should == false
227
- instance.hooks_suspended?( :include ).should == false
228
- instance.hooks_suspended?( :prepend_extend ).should == true
229
- instance.hooks_suspended?( :extend ).should == false
230
- instance.resume_prepend_extend_hooks
231
-
232
- # suspend extend
233
- instance.suspend_extend_hooks
234
- instance.hooks_suspended?( :prepend_include ).should == false
235
- instance.hooks_suspended?( :include ).should == false
236
- instance.hooks_suspended?( :prepend_extend ).should == false
237
- instance.hooks_suspended?( :extend ).should == true
238
- instance.resume_extend_hooks
239
-
240
- end
241
-
242
- end