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.
- data/README.md +127 -337
- data/lib/module-cluster.rb +1 -153
- data/lib/module/cluster.rb +341 -0
- data/lib/module/cluster/class_support.rb +22 -0
- data/lib/module/cluster/cluster.rb +10 -0
- data/lib/module/cluster/cluster/cluster_interface.rb +550 -0
- data/lib/module/cluster/exception/module_not_in_stack.rb +26 -0
- data/lib/module/cluster/instance_controller.rb +14 -0
- data/lib/module/cluster/instance_controller/hook_controller.rb +33 -0
- data/lib/module/cluster/instance_controller/hook_controller/chain_proxy.rb +511 -0
- data/lib/module/cluster/instance_controller/hook_controller/hook_controller_interface.rb +830 -0
- data/lib/module/cluster/instance_controller/instance_controller_interface.rb +269 -0
- data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy.rb +359 -0
- data/lib/module/cluster/instance_controller/multiple_hook_controller_proxy/chain_proxy.rb +442 -0
- data/lib/module/cluster/module_support.rb +67 -0
- data/lib/module/namespaces.rb +13 -0
- data/lib/module/requires.rb +32 -0
- data/spec/module/cluster/cluster_spec.rb +473 -0
- data/spec/module/cluster/instance_controller/hook_controller_spec.rb +922 -0
- data/spec/module/cluster/instance_controller/multiple_hook_controller_proxy_spec.rb +1240 -0
- data/spec/module/cluster_spec.rb +1794 -0
- metadata +27 -98
- data/README.rdoc +0 -395
- data/lib/module-cluster/ModuleCluster.rb +0 -9
- data/lib/module-cluster/ModuleCluster/Define.rb +0 -12
- data/lib/module-cluster/ModuleCluster/Define/Block.rb +0 -9
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClass.rb +0 -83
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingClassOrModule.rb +0 -70
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModule.rb +0 -79
- data/lib/module-cluster/ModuleCluster/Define/Block/CascadingModuleOrSubclass.rb +0 -21
- data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +0 -77
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrSubclass.rb +0 -36
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrSubclass.rb +0 -29
- data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +0 -45
- data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +0 -77
- data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +0 -78
- data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrSubclass.rb +0 -29
- data/lib/module-cluster/ModuleCluster/Define/Block/Subclass.rb +0 -56
- data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +0 -193
- data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +0 -128
- data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +0 -181
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +0 -185
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +0 -181
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +0 -181
- data/lib/module-cluster/ModuleCluster/Define/Deprecated.rb +0 -40
- data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +0 -45
- data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +0 -193
- data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +0 -209
- data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +0 -128
- data/lib/module-cluster/ModuleCluster/Define/Status.rb +0 -106
- data/lib/module-cluster/ModuleCluster/Suspend.rb +0 -7
- data/lib/module-cluster/ModuleCluster/Suspend/Hooks.rb +0 -315
- data/lib/module-cluster/ModuleCluster/Suspend/WithoutHooks.rb +0 -153
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +0 -77
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +0 -44
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +0 -292
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/Subclass.rb +0 -24
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack.rb +0 -12
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block.rb +0 -9
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Inherited.rb +0 -20
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +0 -20
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +0 -6
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +0 -140
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +0 -110
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -140
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -110
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +0 -35
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy.rb +0 -359
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Status.rb +0 -55
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Suspend.rb +0 -199
- data/lib/module-cluster/_private_/ModuleCluster/ExtendForCascade.rb +0 -34
- data/spec/ModuleCluster/Define/Block/CascadingClassOrModule_spec.rb +0 -285
- data/spec/ModuleCluster/Define/Block/CascadingClass_spec.rb +0 -254
- data/spec/ModuleCluster/Define/Block/CascadingModuleOrSubclass_spec.rb +0 -56
- data/spec/ModuleCluster/Define/Block/CascadingModule_spec.rb +0 -278
- data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +0 -230
- data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +0 -238
- data/spec/ModuleCluster/Define/Block/ClassOrModuleOrSubclass_spec.rb +0 -54
- data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +0 -231
- data/spec/ModuleCluster/Define/Block/ClassOrSubclass_spec.rb +0 -54
- data/spec/ModuleCluster/Define/Block/Class_spec.rb +0 -224
- data/spec/ModuleCluster/Define/Block/Instance_spec.rb +0 -78
- data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +0 -54
- data/spec/ModuleCluster/Define/Block/ModuleOrSubclass_spec.rb +0 -51
- data/spec/ModuleCluster/Define/Block/Module_spec.rb +0 -230
- data/spec/ModuleCluster/Define/Block/Subclass_spec.rb +0 -73
- data/spec/ModuleCluster/Define/Block_spec.rb +0 -18
- data/spec/ModuleCluster/Define/ClassCluster_spec.rb +0 -728
- data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +0 -576
- data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +0 -659
- data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +0 -678
- data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +0 -644
- data/spec/ModuleCluster/Define/Cluster_spec.rb +0 -708
- data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +0 -102
- data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +0 -728
- data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +0 -728
- data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +0 -576
- data/spec/ModuleCluster/Suspend/Hooks_spec.rb +0 -573
- data/spec/ModuleCluster/Suspend/WithoutHooks_spec.rb +0 -559
- data/spec/ModuleCluster_spec.rb +0 -15
- data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +0 -386
- data/spec/_private_/ModuleCluster/ClusterStack/Set/MultiSetProxy_spec.rb +0 -419
- data/spec/_private_/ModuleCluster/ClusterStack/Suspend_spec.rb +0 -242
@@ -1,78 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../../lib/module-cluster.rb'
|
3
|
-
|
4
|
-
describe ::ModuleCluster::Define::Block::Instance do
|
5
|
-
|
6
|
-
#####################
|
7
|
-
# instance_extend #
|
8
|
-
#####################
|
9
|
-
|
10
|
-
it 'can run a block on instance extend' do
|
11
|
-
module ::ModuleCluster::Define::Block::Instance::Mock01
|
12
|
-
extend ::ModuleCluster::Define::Block::Instance
|
13
|
-
block_ran = false
|
14
|
-
instance_extend do
|
15
|
-
block_ran = true
|
16
|
-
self.should == ::ModuleCluster::Define::Block::Instance::Mock01
|
17
|
-
end
|
18
|
-
respond_to?( :extended ).should == true
|
19
|
-
module ModuleProof
|
20
|
-
include ::ModuleCluster::Define::Block::Instance::Mock01
|
21
|
-
end
|
22
|
-
block_ran.should == false
|
23
|
-
module ModuleProof2
|
24
|
-
extend ::ModuleCluster::Define::Block::Instance::Mock01
|
25
|
-
end
|
26
|
-
block_ran.should == false
|
27
|
-
class ClassProof
|
28
|
-
include ::ModuleCluster::Define::Block::Instance::Mock01
|
29
|
-
end
|
30
|
-
block_ran.should == false
|
31
|
-
class ClassProof2
|
32
|
-
extend ::ModuleCluster::Define::Block::Instance::Mock01
|
33
|
-
end
|
34
|
-
block_ran.should == false
|
35
|
-
Object.new.instance_eval do
|
36
|
-
extend ::ModuleCluster::Define::Block::Instance::Mock01
|
37
|
-
end
|
38
|
-
block_ran.should == true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
#############################
|
43
|
-
# prepend_instance_extend #
|
44
|
-
#############################
|
45
|
-
|
46
|
-
it 'can run a block before instance extend' do
|
47
|
-
module ::ModuleCluster::Define::Block::Instance::Mock02
|
48
|
-
extend ::ModuleCluster::Define::Block::Instance
|
49
|
-
block_ran = false
|
50
|
-
prepend_instance_extend do
|
51
|
-
block_ran = true
|
52
|
-
self.should == ::ModuleCluster::Define::Block::Instance::Mock02
|
53
|
-
end
|
54
|
-
respond_to?( :extended ).should == true
|
55
|
-
module ModuleProof
|
56
|
-
include ::ModuleCluster::Define::Block::Instance::Mock02
|
57
|
-
end
|
58
|
-
block_ran.should == false
|
59
|
-
module ModuleProof2
|
60
|
-
extend ::ModuleCluster::Define::Block::Instance::Mock02
|
61
|
-
end
|
62
|
-
block_ran.should == false
|
63
|
-
class ClassProof
|
64
|
-
include ::ModuleCluster::Define::Block::Instance::Mock02
|
65
|
-
end
|
66
|
-
block_ran.should == false
|
67
|
-
class ClassProof2
|
68
|
-
extend ::ModuleCluster::Define::Block::Instance::Mock02
|
69
|
-
end
|
70
|
-
block_ran.should == false
|
71
|
-
Object.new.instance_eval do
|
72
|
-
extend ::ModuleCluster::Define::Block::Instance::Mock02
|
73
|
-
end
|
74
|
-
block_ran.should == true
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../../lib/module-cluster.rb'
|
3
|
-
|
4
|
-
describe ::ModuleCluster::Define::Block::ModuleOrInstance do
|
5
|
-
|
6
|
-
###############################
|
7
|
-
# module_or_instance_extend #
|
8
|
-
###############################
|
9
|
-
|
10
|
-
it '' do
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
#######################################
|
15
|
-
# module_include_or_instance_extend #
|
16
|
-
#######################################
|
17
|
-
|
18
|
-
it '' do
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
#################################################
|
23
|
-
# module_include_or_extend_or_instance_extend #
|
24
|
-
#################################################
|
25
|
-
|
26
|
-
it '' do
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
#######################################
|
31
|
-
# prepend_module_or_instance_extend #
|
32
|
-
#######################################
|
33
|
-
|
34
|
-
it '' do
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
###############################################
|
39
|
-
# prepend_module_include_or_instance_extend #
|
40
|
-
###############################################
|
41
|
-
|
42
|
-
it '' do
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
#########################################################
|
47
|
-
# prepend_module_include_or_extend_or_instance_extend #
|
48
|
-
#########################################################
|
49
|
-
|
50
|
-
it '' do
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../../lib/module-cluster.rb'
|
3
|
-
|
4
|
-
describe ::ModuleCluster::Define::Block::ModuleOrSubclass do
|
5
|
-
|
6
|
-
################################
|
7
|
-
# module_include_or_subclass #
|
8
|
-
################################
|
9
|
-
|
10
|
-
it 'can run a block on class or module extend' do
|
11
|
-
module ::ModuleCluster::Define::Block::ModuleOrSubclass::Mock01
|
12
|
-
extend ::ModuleCluster::Define::Block::ModuleOrSubclass
|
13
|
-
block_ran = false
|
14
|
-
module_include_or_subclass do
|
15
|
-
block_ran = true
|
16
|
-
end
|
17
|
-
respond_to?( :extended ).should == true
|
18
|
-
module ModuleProof
|
19
|
-
include ::ModuleCluster::Define::Block::ModuleOrSubclass::Mock01
|
20
|
-
end
|
21
|
-
block_ran.should == true
|
22
|
-
block_ran = false
|
23
|
-
module ModuleProof2
|
24
|
-
extend ::ModuleCluster::Define::Block::ModuleOrSubclass::Mock01
|
25
|
-
end
|
26
|
-
block_ran.should == false
|
27
|
-
block_ran = false
|
28
|
-
class ClassProof
|
29
|
-
include ::ModuleCluster::Define::Block::ModuleOrSubclass::Mock01
|
30
|
-
end
|
31
|
-
block_ran.should == false
|
32
|
-
class ClassProof2
|
33
|
-
extend ::ModuleCluster::Define::Block::ModuleOrSubclass::Mock01
|
34
|
-
end
|
35
|
-
block_ran.should == false
|
36
|
-
block_ran = false
|
37
|
-
Object.new.instance_eval do
|
38
|
-
extend ::ModuleCluster::Define::Block::ModuleOrSubclass::Mock01
|
39
|
-
end
|
40
|
-
block_ran.should == false
|
41
|
-
class SubClassProof < ClassProof
|
42
|
-
end
|
43
|
-
block_ran.should == true
|
44
|
-
block_ran = false
|
45
|
-
class SubSubClassProof < SubClassProof
|
46
|
-
end
|
47
|
-
block_ran.should == true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,230 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../../lib/module-cluster.rb'
|
3
|
-
|
4
|
-
describe ::ModuleCluster::Define::Block::Module do
|
5
|
-
|
6
|
-
####################
|
7
|
-
# module_include #
|
8
|
-
####################
|
9
|
-
|
10
|
-
it 'can run a block on module include' do
|
11
|
-
module ::ModuleCluster::Define::Block::Module::Mock01
|
12
|
-
extend ::ModuleCluster::Define::Block::Module
|
13
|
-
block_ran = false
|
14
|
-
module_include do
|
15
|
-
block_ran = true
|
16
|
-
self.should == ::ModuleCluster::Define::Block::Module::Mock01
|
17
|
-
end
|
18
|
-
cluster_stack.include_hooks.count.should == 1
|
19
|
-
respond_to?( :included ).should == true
|
20
|
-
class ClassProof
|
21
|
-
extend ::ModuleCluster::Define::Block::Module::Mock01
|
22
|
-
respond_to?( :cluster_stack ).should == false
|
23
|
-
end
|
24
|
-
block_ran.should == false
|
25
|
-
class ClassProof2
|
26
|
-
include ::ModuleCluster::Define::Block::Module::Mock01
|
27
|
-
respond_to?( :cluster_stack ).should == false
|
28
|
-
end
|
29
|
-
block_ran.should == false
|
30
|
-
Object.new.instance_eval do
|
31
|
-
extend ::ModuleCluster::Define::Block::Module::Mock01
|
32
|
-
respond_to?( :cluster_stack ).should == false
|
33
|
-
end
|
34
|
-
block_ran.should == false
|
35
|
-
module ModuleProof
|
36
|
-
extend ::ModuleCluster::Define::Block::Module::Mock01
|
37
|
-
respond_to?( :cluster_stack ).should == false
|
38
|
-
end
|
39
|
-
block_ran.should == false
|
40
|
-
module ModuleProof2
|
41
|
-
include ::ModuleCluster::Define::Block::Module::Mock01
|
42
|
-
respond_to?( :cluster_stack ).should == false
|
43
|
-
end
|
44
|
-
block_ran.should == true
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
###################
|
49
|
-
# module_extend #
|
50
|
-
###################
|
51
|
-
|
52
|
-
it 'can run a block on module extend' do
|
53
|
-
module ::ModuleCluster::Define::Block::Module::Mock02
|
54
|
-
extend ::ModuleCluster::Define::Block::Module
|
55
|
-
block_ran = false
|
56
|
-
module_extend do
|
57
|
-
block_ran = true
|
58
|
-
self.should == ::ModuleCluster::Define::Block::Module::Mock02
|
59
|
-
end
|
60
|
-
respond_to?( :extended ).should == true
|
61
|
-
class ClassProof
|
62
|
-
include ::ModuleCluster::Define::Block::Module::Mock02
|
63
|
-
end
|
64
|
-
block_ran.should == false
|
65
|
-
class ClassProof2
|
66
|
-
extend ::ModuleCluster::Define::Block::Module::Mock02
|
67
|
-
end
|
68
|
-
block_ran.should == false
|
69
|
-
Object.new.instance_eval do
|
70
|
-
extend ::ModuleCluster::Define::Block::Module::Mock02
|
71
|
-
end
|
72
|
-
block_ran.should == false
|
73
|
-
module ModuleProof
|
74
|
-
include ::ModuleCluster::Define::Block::Module::Mock02
|
75
|
-
end
|
76
|
-
block_ran.should == false
|
77
|
-
module ModuleProof2
|
78
|
-
extend ::ModuleCluster::Define::Block::Module::Mock02
|
79
|
-
end
|
80
|
-
block_ran.should == true
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
##############################
|
85
|
-
# module_include_or_extend #
|
86
|
-
##############################
|
87
|
-
|
88
|
-
it 'can run a block on module include or extend' do
|
89
|
-
module ::ModuleCluster::Define::Block::Module::Mock03
|
90
|
-
extend ::ModuleCluster::Define::Block::Module
|
91
|
-
block_ran = false
|
92
|
-
module_include_or_extend do
|
93
|
-
block_ran = true
|
94
|
-
self.should == ::ModuleCluster::Define::Block::Module::Mock03
|
95
|
-
end
|
96
|
-
respond_to?( :extended ).should == true
|
97
|
-
class ClassProof
|
98
|
-
include ::ModuleCluster::Define::Block::Module::Mock03
|
99
|
-
end
|
100
|
-
block_ran.should == false
|
101
|
-
class ClassProof2
|
102
|
-
extend ::ModuleCluster::Define::Block::Module::Mock03
|
103
|
-
end
|
104
|
-
block_ran.should == false
|
105
|
-
Object.new.instance_eval do
|
106
|
-
extend ::ModuleCluster::Define::Block::Module::Mock03
|
107
|
-
end
|
108
|
-
block_ran.should == false
|
109
|
-
module ModuleProof
|
110
|
-
include ::ModuleCluster::Define::Block::Module::Mock03
|
111
|
-
end
|
112
|
-
block_ran.should == true
|
113
|
-
block_ran = false
|
114
|
-
module ModuleProof2
|
115
|
-
extend ::ModuleCluster::Define::Block::Module::Mock03
|
116
|
-
end
|
117
|
-
block_ran.should == true
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
############################
|
122
|
-
# prepend_module_include #
|
123
|
-
############################
|
124
|
-
|
125
|
-
it 'can run a block before module include' do
|
126
|
-
module ::ModuleCluster::Define::Block::Module::Mock04
|
127
|
-
extend ::ModuleCluster::Define::Block::Module
|
128
|
-
block_ran = false
|
129
|
-
prepend_module_include do
|
130
|
-
block_ran = true
|
131
|
-
self.should == ::ModuleCluster::Define::Block::Module::Mock04
|
132
|
-
end
|
133
|
-
respond_to?( :included ).should == true
|
134
|
-
class ClassProof
|
135
|
-
extend ::ModuleCluster::Define::Block::Module::Mock04
|
136
|
-
end
|
137
|
-
block_ran.should == false
|
138
|
-
class ClassProof2
|
139
|
-
include ::ModuleCluster::Define::Block::Module::Mock04
|
140
|
-
end
|
141
|
-
block_ran.should == false
|
142
|
-
Object.new.instance_eval do
|
143
|
-
extend ::ModuleCluster::Define::Block::Module::Mock04
|
144
|
-
end
|
145
|
-
block_ran.should == false
|
146
|
-
module ModuleProof
|
147
|
-
extend ::ModuleCluster::Define::Block::Module::Mock04
|
148
|
-
end
|
149
|
-
block_ran.should == false
|
150
|
-
module ModuleProof2
|
151
|
-
include ::ModuleCluster::Define::Block::Module::Mock04
|
152
|
-
end
|
153
|
-
block_ran.should == true
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
###########################
|
158
|
-
# prepend_module_extend #
|
159
|
-
###########################
|
160
|
-
|
161
|
-
it 'can run a block before module extend' do
|
162
|
-
module ::ModuleCluster::Define::Block::Module::Mock05
|
163
|
-
extend ::ModuleCluster::Define::Block::Module
|
164
|
-
block_ran = false
|
165
|
-
prepend_module_extend do
|
166
|
-
block_ran = true
|
167
|
-
self.should == ::ModuleCluster::Define::Block::Module::Mock05
|
168
|
-
end
|
169
|
-
respond_to?( :extended ).should == true
|
170
|
-
class ClassProof
|
171
|
-
include ::ModuleCluster::Define::Block::Module::Mock05
|
172
|
-
end
|
173
|
-
block_ran.should == false
|
174
|
-
class ClassProof2
|
175
|
-
extend ::ModuleCluster::Define::Block::Module::Mock05
|
176
|
-
end
|
177
|
-
block_ran.should == false
|
178
|
-
Object.new.instance_eval do
|
179
|
-
extend ::ModuleCluster::Define::Block::Module::Mock05
|
180
|
-
end
|
181
|
-
block_ran.should == false
|
182
|
-
module ModuleProof
|
183
|
-
include ::ModuleCluster::Define::Block::Module::Mock05
|
184
|
-
end
|
185
|
-
block_ran.should == false
|
186
|
-
module ModuleProof2
|
187
|
-
extend ::ModuleCluster::Define::Block::Module::Mock05
|
188
|
-
end
|
189
|
-
block_ran.should == true
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
######################################
|
194
|
-
# prepend_module_include_or_extend #
|
195
|
-
######################################
|
196
|
-
|
197
|
-
it 'can run a block before module include or extend' do
|
198
|
-
module ::ModuleCluster::Define::Block::Module::Mock06
|
199
|
-
extend ::ModuleCluster::Define::Block::Module
|
200
|
-
block_ran = false
|
201
|
-
prepend_module_include_or_extend do
|
202
|
-
block_ran = true
|
203
|
-
self.should == ::ModuleCluster::Define::Block::Module::Mock06
|
204
|
-
end
|
205
|
-
respond_to?( :extended ).should == true
|
206
|
-
class ClassProof
|
207
|
-
include ::ModuleCluster::Define::Block::Module::Mock06
|
208
|
-
end
|
209
|
-
block_ran.should == false
|
210
|
-
class ClassProof2
|
211
|
-
extend ::ModuleCluster::Define::Block::Module::Mock06
|
212
|
-
end
|
213
|
-
block_ran.should == false
|
214
|
-
Object.new.instance_eval do
|
215
|
-
extend ::ModuleCluster::Define::Block::Module::Mock06
|
216
|
-
end
|
217
|
-
block_ran.should == false
|
218
|
-
module ModuleProof
|
219
|
-
include ::ModuleCluster::Define::Block::Module::Mock06
|
220
|
-
end
|
221
|
-
block_ran.should == true
|
222
|
-
block_ran = false
|
223
|
-
module ModuleProof2
|
224
|
-
extend ::ModuleCluster::Define::Block::Module::Mock06
|
225
|
-
end
|
226
|
-
block_ran.should == true
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../../../lib/module-cluster.rb'
|
3
|
-
|
4
|
-
describe ::ModuleCluster::Define::Block::Subclass do
|
5
|
-
|
6
|
-
##############
|
7
|
-
# subclass #
|
8
|
-
##############
|
9
|
-
|
10
|
-
it 'can run a block when a class is subclassed' do
|
11
|
-
|
12
|
-
class ::ModuleCluster::Define::Block::Subclass::Mock01
|
13
|
-
extend ::ModuleCluster::Define::Block::Subclass
|
14
|
-
block_ran = false
|
15
|
-
subclass do |subclass_instance|
|
16
|
-
subclass_instance.ancestors[ 1 ].should == self
|
17
|
-
self.ancestors.include?( ::ModuleCluster::Define::Block::Subclass::Mock01 ).should == true
|
18
|
-
subclass_instance.ancestors.include?( ::ModuleCluster::Define::Block::Subclass::Mock01 ).should == true
|
19
|
-
block_ran = true
|
20
|
-
end
|
21
|
-
respond_to?( :inherited ).should == true
|
22
|
-
respond_to?( :included ).should == false
|
23
|
-
respond_to?( :extended ).should == false
|
24
|
-
respond_to?( :append_features ).should == false
|
25
|
-
respond_to?( :extend_object ).should == false
|
26
|
-
class ModuleProof < ::ModuleCluster::Define::Block::Subclass::Mock01
|
27
|
-
end
|
28
|
-
block_ran.should == true
|
29
|
-
block_ran = false
|
30
|
-
class ModuleProof2 < ModuleProof
|
31
|
-
end
|
32
|
-
block_ran.should == true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'can run a block when a class is subclassed after a module has defined subclassing' do
|
37
|
-
|
38
|
-
module ::ModuleCluster::Define::Block::Subclass::Mock02
|
39
|
-
extend ::ModuleCluster::Define::Block::Subclass
|
40
|
-
block_ran = false
|
41
|
-
subclass do |subclass_instance|
|
42
|
-
subclass_instance.ancestors[ 1 ].should == self
|
43
|
-
self.ancestors.include?( ::ModuleCluster::Define::Block::Subclass::Mock02 ).should == true
|
44
|
-
subclass_instance.ancestors.include?( ::ModuleCluster::Define::Block::Subclass::Mock02 ).should == true
|
45
|
-
block_ran = true
|
46
|
-
end
|
47
|
-
respond_to?( :included ).should == true
|
48
|
-
respond_to?( :extended ).should == true
|
49
|
-
respond_to?( :append_features ).should == true
|
50
|
-
respond_to?( :extend_object ).should == true
|
51
|
-
respond_to?( :inherited ).should == false
|
52
|
-
class ClassProof
|
53
|
-
include ::ModuleCluster::Define::Block::Subclass::Mock02
|
54
|
-
respond_to?( :inherited ).should == true
|
55
|
-
respond_to?( :included ).should == false
|
56
|
-
respond_to?( :extended ).should == false
|
57
|
-
respond_to?( :append_features ).should == false
|
58
|
-
respond_to?( :extend_object ).should == false
|
59
|
-
end
|
60
|
-
block_ran.should == false
|
61
|
-
block_ran = false
|
62
|
-
class ClassProof2 < ClassProof
|
63
|
-
end
|
64
|
-
block_ran.should == true
|
65
|
-
block_ran = false
|
66
|
-
class ClassProof3 < ClassProof2
|
67
|
-
end
|
68
|
-
block_ran.should == true
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|