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,559 +0,0 @@
1
-
2
- require_relative '../../../lib/module-cluster.rb'
3
-
4
- describe ::ModuleCluster::Suspend::WithoutHooks do
5
-
6
- #######################
7
- # without_any_hooks #
8
- #######################
9
-
10
- it 'can suspend and resume all hooks at once or all hooks matching a description' do
11
- module ::ModuleCluster::Suspend::WithoutHooks::Mock01
12
- extend ::ModuleCluster::Suspend::WithoutHooks
13
- # required to provide #cluster_stack
14
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
15
- module Module1
16
- end
17
- module Module2
18
- end
19
- module Module3
20
- end
21
- module Module4
22
- end
23
- # prepend include
24
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
25
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
26
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
27
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
28
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
29
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
30
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
31
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
32
- # prepend extend
33
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
34
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
35
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
36
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
37
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
38
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
39
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
40
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
41
- # include
42
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
43
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
44
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
45
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
46
- cluster_stack.include_hooks.push( include_set_one )
47
- cluster_stack.include_hooks.push( include_set_two )
48
- cluster_stack.include_hooks.push( include_set_three )
49
- cluster_stack.include_hooks.push( include_set_four )
50
- # extend
51
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
52
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
53
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
54
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
55
- cluster_stack.extend_hooks.push( extend_set_one )
56
- cluster_stack.extend_hooks.push( extend_set_two )
57
- cluster_stack.extend_hooks.push( extend_set_three )
58
- cluster_stack.extend_hooks.push( extend_set_four )
59
-
60
- # suspend all hooks
61
- without_any_hooks do
62
- all_hooks_suspended?.should == true
63
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
64
- end
65
- all_hooks_suspended?.should == false
66
-
67
- # suspend hooks by description
68
- without_any_hooks( :name => :one ) do
69
- all_hooks_suspended?.should == false
70
- prepend_include_set_one.suspended.should == true
71
- prepend_extend_set_one.suspended.should == true
72
- include_set_one.suspended.should == true
73
- extend_set_one.suspended.should == true
74
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
75
- end
76
- prepend_include_set_one.suspended.should == false
77
- prepend_extend_set_one.suspended.should == false
78
- include_set_one.suspended.should == false
79
- extend_set_one.suspended.should == false
80
- all_hooks_suspended?.should == false
81
-
82
- end
83
- end
84
-
85
- ###############################
86
- # without_any_include_hooks #
87
- ###############################
88
-
89
- it 'can suspend and resume all include or prepending include hooks at once or any include or prepending include hooks matching a description' do
90
- module ::ModuleCluster::Suspend::WithoutHooks::Mock02
91
- extend ::ModuleCluster::Suspend::WithoutHooks
92
- # required to provide #cluster_stack
93
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
94
- module Module1
95
- end
96
- module Module2
97
- end
98
- module Module3
99
- end
100
- module Module4
101
- end
102
- # prepend include
103
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
104
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
105
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
106
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
107
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
108
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
109
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
110
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
111
- # prepend extend
112
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
113
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
114
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
115
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
116
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
117
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
118
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
119
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
120
- # include
121
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
122
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
123
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
124
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
125
- cluster_stack.include_hooks.push( include_set_one )
126
- cluster_stack.include_hooks.push( include_set_two )
127
- cluster_stack.include_hooks.push( include_set_three )
128
- cluster_stack.include_hooks.push( include_set_four )
129
- # extend
130
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
131
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
132
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
133
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
134
- cluster_stack.extend_hooks.push( extend_set_one )
135
- cluster_stack.extend_hooks.push( extend_set_two )
136
- cluster_stack.extend_hooks.push( extend_set_three )
137
- cluster_stack.extend_hooks.push( extend_set_four )
138
-
139
- # suspend all hooks
140
- suspend_any_include_hooks
141
- all_include_hooks_suspended?.should == true
142
- cluster_stack.all_include_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
143
- resume_any_include_hooks
144
- all_include_hooks_suspended?.should == false
145
-
146
- # suspend hooks by description
147
- suspend_any_include_hooks( :name => :one )
148
- all_include_hooks_suspended?.should == false
149
- prepend_include_set_one.suspended.should == true
150
- prepend_extend_set_one.suspended.should == false
151
- include_set_one.suspended.should == true
152
- extend_set_one.suspended.should == false
153
- cluster_stack.all_include_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
154
- resume_any_include_hooks( :name => :one )
155
- prepend_include_set_one.suspended.should == false
156
- prepend_extend_set_one.suspended.should == false
157
- include_set_one.suspended.should == false
158
- extend_set_one.suspended.should == false
159
- all_include_hooks_suspended?.should == false
160
-
161
- end
162
- end
163
-
164
- ##############################
165
- # without_any_extend_hooks #
166
- ##############################
167
-
168
- it 'can suspend and resume all extend or prepending extend hooks at once or any extend or prepending extend hooks matching a description' do
169
- module ::ModuleCluster::Suspend::WithoutHooks::Mock03
170
- extend ::ModuleCluster::Suspend::WithoutHooks
171
- # required to provide #cluster_stack
172
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
173
- module Module1
174
- end
175
- module Module2
176
- end
177
- module Module3
178
- end
179
- module Module4
180
- end
181
- # prepend include
182
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
183
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
184
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
185
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
186
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
187
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
188
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
189
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
190
- # prepend extend
191
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
192
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
193
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
194
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
195
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
196
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
197
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
198
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
199
- # include
200
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
201
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
202
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
203
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
204
- cluster_stack.include_hooks.push( include_set_one )
205
- cluster_stack.include_hooks.push( include_set_two )
206
- cluster_stack.include_hooks.push( include_set_three )
207
- cluster_stack.include_hooks.push( include_set_four )
208
- # extend
209
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
210
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
211
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
212
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
213
- cluster_stack.extend_hooks.push( extend_set_one )
214
- cluster_stack.extend_hooks.push( extend_set_two )
215
- cluster_stack.extend_hooks.push( extend_set_three )
216
- cluster_stack.extend_hooks.push( extend_set_four )
217
-
218
- # suspend all hooks
219
- without_any_extend_hooks do
220
- all_extend_hooks_suspended?.should == true
221
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
222
- end
223
- all_extend_hooks_suspended?.should == false
224
-
225
- # suspend hooks by description
226
- without_any_extend_hooks( :name => :one ) do
227
- all_extend_hooks_suspended?.should == false
228
- prepend_include_set_one.suspended.should == false
229
- prepend_extend_set_one.suspended.should == true
230
- include_set_one.suspended.should == false
231
- extend_set_one.suspended.should == true
232
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
233
- end
234
- prepend_include_set_one.suspended.should == false
235
- prepend_extend_set_one.suspended.should == false
236
- include_set_one.suspended.should == false
237
- extend_set_one.suspended.should == false
238
- all_extend_hooks_suspended?.should == false
239
-
240
- end
241
- end
242
-
243
- ###########################
244
- # without_include_hooks #
245
- ###########################
246
-
247
- it 'can suspend and resume all include hooks at once or any include hooks matching a description' do
248
- module ::ModuleCluster::Suspend::WithoutHooks::Mock04
249
- extend ::ModuleCluster::Suspend::WithoutHooks
250
- # required to provide #cluster_stack
251
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
252
- module Module1
253
- end
254
- module Module2
255
- end
256
- module Module3
257
- end
258
- module Module4
259
- end
260
- # prepend include
261
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
262
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
263
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
264
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
265
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
266
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
267
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
268
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
269
- # prepend extend
270
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
271
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
272
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
273
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
274
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
275
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
276
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
277
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
278
- # include
279
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
280
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
281
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
282
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
283
- cluster_stack.include_hooks.push( include_set_one )
284
- cluster_stack.include_hooks.push( include_set_two )
285
- cluster_stack.include_hooks.push( include_set_three )
286
- cluster_stack.include_hooks.push( include_set_four )
287
- # extend
288
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
289
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
290
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
291
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
292
- cluster_stack.extend_hooks.push( extend_set_one )
293
- cluster_stack.extend_hooks.push( extend_set_two )
294
- cluster_stack.extend_hooks.push( extend_set_three )
295
- cluster_stack.extend_hooks.push( extend_set_four )
296
-
297
- # suspend all hooks
298
- without_include_hooks do
299
- include_hooks_suspended?.should == true
300
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
301
- end
302
- include_hooks_suspended?.should == false
303
-
304
- # suspend hooks by description
305
- without_include_hooks( :name => :one ) do
306
- include_hooks_suspended?.should == false
307
- prepend_include_set_one.suspended.should == false
308
- prepend_extend_set_one.suspended.should == false
309
- include_set_one.suspended.should == true
310
- extend_set_one.suspended.should == false
311
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
312
- end
313
- prepend_include_set_one.suspended.should == false
314
- prepend_extend_set_one.suspended.should == false
315
- include_set_one.suspended.should == false
316
- extend_set_one.suspended.should == false
317
- include_hooks_suspended?.should == false
318
-
319
- end
320
- end
321
-
322
- ##########################
323
- # without_extend_hooks #
324
- ##########################
325
-
326
- it 'can suspend and resume all extend hooks at once or any extend hooks matching a description' do
327
- module ::ModuleCluster::Suspend::WithoutHooks::Mock05
328
- extend ::ModuleCluster::Suspend::WithoutHooks
329
- # required to provide #cluster_stack
330
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
331
- module Module1
332
- end
333
- module Module2
334
- end
335
- module Module3
336
- end
337
- module Module4
338
- end
339
- # prepend include
340
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
341
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
342
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
343
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
344
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
345
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
346
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
347
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
348
- # prepend extend
349
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
350
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
351
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
352
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
353
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
354
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
355
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
356
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
357
- # include
358
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
359
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
360
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
361
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
362
- cluster_stack.include_hooks.push( include_set_one )
363
- cluster_stack.include_hooks.push( include_set_two )
364
- cluster_stack.include_hooks.push( include_set_three )
365
- cluster_stack.include_hooks.push( include_set_four )
366
- # extend
367
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
368
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
369
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
370
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
371
- cluster_stack.extend_hooks.push( extend_set_one )
372
- cluster_stack.extend_hooks.push( extend_set_two )
373
- cluster_stack.extend_hooks.push( extend_set_three )
374
- cluster_stack.extend_hooks.push( extend_set_four )
375
-
376
- # suspend all hooks
377
- without_extend_hooks do
378
- extend_hooks_suspended?.should == true
379
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
380
- end
381
- extend_hooks_suspended?.should == false
382
-
383
- # suspend hooks by description
384
- without_extend_hooks( :name => :one ) do
385
- extend_hooks_suspended?.should == false
386
- prepend_include_set_one.suspended.should == false
387
- prepend_extend_set_one.suspended.should == false
388
- include_set_one.suspended.should == false
389
- extend_set_one.suspended.should == true
390
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
391
- end
392
- prepend_include_set_one.suspended.should == false
393
- prepend_extend_set_one.suspended.should == false
394
- include_set_one.suspended.should == false
395
- extend_set_one.suspended.should == false
396
- extend_hooks_suspended?.should == false
397
-
398
- end
399
- end
400
-
401
- ###################################
402
- # without_prepend_include_hooks #
403
- ###################################
404
-
405
- it 'can suspend and resume all prepending include hooks at once or any prepending include hooks matching a description' do
406
- module ::ModuleCluster::Suspend::WithoutHooks::Mock06
407
- extend ::ModuleCluster::Suspend::WithoutHooks
408
- # required to provide #cluster_stack
409
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
410
- module Module1
411
- end
412
- module Module2
413
- end
414
- module Module3
415
- end
416
- module Module4
417
- end
418
- # prepend include
419
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
420
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
421
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
422
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
423
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
424
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
425
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
426
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
427
- # prepend extend
428
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
429
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
430
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
431
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
432
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
433
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
434
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
435
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
436
- # include
437
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
438
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
439
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
440
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
441
- cluster_stack.include_hooks.push( include_set_one )
442
- cluster_stack.include_hooks.push( include_set_two )
443
- cluster_stack.include_hooks.push( include_set_three )
444
- cluster_stack.include_hooks.push( include_set_four )
445
- # extend
446
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
447
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
448
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
449
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
450
- cluster_stack.extend_hooks.push( extend_set_one )
451
- cluster_stack.extend_hooks.push( extend_set_two )
452
- cluster_stack.extend_hooks.push( extend_set_three )
453
- cluster_stack.extend_hooks.push( extend_set_four )
454
-
455
- # suspend all hooks
456
- without_prepend_include_hooks do
457
- prepend_include_hooks_suspended?.should == true
458
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
459
- end
460
- prepend_include_hooks_suspended?.should == false
461
-
462
- # suspend hooks by description
463
- without_prepend_include_hooks( :name => :one ) do
464
- prepend_include_hooks_suspended?.should == false
465
- prepend_include_set_one.suspended.should == true
466
- prepend_extend_set_one.suspended.should == false
467
- include_set_one.suspended.should == false
468
- extend_set_one.suspended.should == false
469
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
470
- end
471
- prepend_include_set_one.suspended.should == false
472
- prepend_extend_set_one.suspended.should == false
473
- include_set_one.suspended.should == false
474
- extend_set_one.suspended.should == false
475
- prepend_include_hooks_suspended?.should == false
476
-
477
- end
478
- end
479
-
480
- ##################################
481
- # without_prepend_extend_hooks #
482
- ##################################
483
-
484
- it 'can suspend and resume all prepending extend hooks at once or any prepending extend hooks matching a description' do
485
- module ::ModuleCluster::Suspend::WithoutHooks::Mock07
486
- extend ::ModuleCluster::Suspend::WithoutHooks
487
- # required to provide #cluster_stack
488
- extend ::ModuleCluster::CascadeFeatures::ClusterStack
489
- module Module1
490
- end
491
- module Module2
492
- end
493
- module Module3
494
- end
495
- module Module4
496
- end
497
- # prepend include
498
- prepend_include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
499
- prepend_include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
500
- prepend_include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
501
- prepend_include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
502
- cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
503
- cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
504
- cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
505
- cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
506
- # prepend extend
507
- prepend_extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
508
- prepend_extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
509
- prepend_extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
510
- prepend_extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
511
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
512
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
513
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
514
- cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
515
- # include
516
- include_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
517
- include_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
518
- include_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
519
- include_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
520
- cluster_stack.include_hooks.push( include_set_one )
521
- cluster_stack.include_hooks.push( include_set_two )
522
- cluster_stack.include_hooks.push( include_set_three )
523
- cluster_stack.include_hooks.push( include_set_four )
524
- # extend
525
- extend_set_one = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
526
- extend_set_two = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
527
- extend_set_three = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
528
- extend_set_four = ::ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
529
- cluster_stack.extend_hooks.push( extend_set_one )
530
- cluster_stack.extend_hooks.push( extend_set_two )
531
- cluster_stack.extend_hooks.push( extend_set_three )
532
- cluster_stack.extend_hooks.push( extend_set_four )
533
-
534
- # suspend all hooks
535
- without_prepend_extend_hooks do
536
- prepend_extend_hooks_suspended?.should == true
537
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
538
- end
539
- prepend_extend_hooks_suspended?.should == false
540
-
541
- # suspend hooks by description
542
- without_prepend_extend_hooks( :name => :one ) do
543
- prepend_extend_hooks_suspended?.should == false
544
- prepend_include_set_one.suspended.should == false
545
- prepend_extend_set_one.suspended.should == true
546
- include_set_one.suspended.should == false
547
- extend_set_one.suspended.should == false
548
- cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
549
- end
550
- prepend_include_set_one.suspended.should == false
551
- prepend_extend_set_one.suspended.should == false
552
- include_set_one.suspended.should == false
553
- extend_set_one.suspended.should == false
554
- prepend_extend_hooks_suspended?.should == false
555
-
556
- end
557
- end
558
-
559
- end