module-cluster 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +112 -0
- data/README.rdoc +0 -0
- data/lib/module-cluster.rb +13 -0
- data/lib/module-cluster/ModuleCluster.rb +38 -0
- data/lib/module-cluster/ModuleCluster/ExtendSupport.rb +23 -0
- data/lib/module-cluster/ModuleCluster/IncludeExtendSupport.rb +38 -0
- data/lib/module-cluster/ModuleCluster/IncludeSupport.rb +23 -0
- data/lib/module-cluster/_private_/ModuleCluster.rb +22 -0
- data/spec/ModuleCluster/IncludeExtendSupport_spec.rb +46 -0
- data/spec/ModuleCluster_spec.rb +282 -0
- metadata +73 -0
data/README.md
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# Module Cluster #
|
2
|
+
|
3
|
+
http://rubygems.org/gems/module-cluster
|
4
|
+
|
5
|
+
# Description #
|
6
|
+
|
7
|
+
Adds methods for defining module clusters using #included and #extended.
|
8
|
+
|
9
|
+
# Summary #
|
10
|
+
|
11
|
+
Provides :define_module_inclusion, :define_module_extension, and :define_module_cluster.
|
12
|
+
|
13
|
+
# Install #
|
14
|
+
|
15
|
+
* sudo gem install module-cluster
|
16
|
+
|
17
|
+
# Usage #
|
18
|
+
|
19
|
+
Simply:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
module SomeModule
|
23
|
+
include ModuleCluster
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
To cause modules to be included when this module is included:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
module SomeModule
|
31
|
+
define_module_inclusion do |includes, extends|
|
32
|
+
includes.concat [ SomeOtherModule ]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
or extended when this module is included:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
module SomeModule
|
41
|
+
define_module_inclusion do |includes, extends|
|
42
|
+
extends.concat [ SomeOtherModule ]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
or when this module is extended
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
module SomeModule
|
51
|
+
define_module_extension do |includes, extends|
|
52
|
+
includes.concat [ SomeOtherModule ]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
or
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
module SomeModule
|
61
|
+
define_module_extension do |includes, extends|
|
62
|
+
extends.concat [ SomeOtherModule ]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
or when this module is either included or extended:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
module SomeModule
|
71
|
+
define_module_cluster do |includes, extends|
|
72
|
+
includes.concat [ SomeOtherModule ]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
or
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
module SomeModule
|
81
|
+
define_module_cluster do |includes, extends|
|
82
|
+
extends.concat [ SomeOtherModule ]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
If the block returns [ includes, extends ] as arrays, those values will be used; otherwise, the contents of the includes and extends parameters passed to the block will be used.
|
88
|
+
|
89
|
+
# License #
|
90
|
+
|
91
|
+
(The MIT License)
|
92
|
+
|
93
|
+
Copyright (c) 2011 Asher
|
94
|
+
|
95
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
96
|
+
a copy of this software and associated documentation files (the
|
97
|
+
'Software'), to deal in the Software without restriction, including
|
98
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
99
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
100
|
+
permit persons to whom the Software is furnished to do so, subject to
|
101
|
+
the following conditions:
|
102
|
+
|
103
|
+
The above copyright notice and this permission notice shall be
|
104
|
+
included in all copies or substantial portions of the Software.
|
105
|
+
|
106
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
107
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
108
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
109
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
110
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
111
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
112
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster
|
3
|
+
module IncludeSupport
|
4
|
+
end
|
5
|
+
module ExtendSupport
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require_relative 'module-cluster/ModuleCluster.rb'
|
10
|
+
require_relative 'module-cluster/_private_/ModuleCluster.rb'
|
11
|
+
require_relative 'module-cluster/ModuleCluster/IncludeExtendSupport.rb'
|
12
|
+
require_relative 'module-cluster/ModuleCluster/IncludeSupport.rb'
|
13
|
+
require_relative 'module-cluster/ModuleCluster/ExtendSupport.rb'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster
|
3
|
+
|
4
|
+
#############################
|
5
|
+
# define_module_inclusion #
|
6
|
+
#############################
|
7
|
+
|
8
|
+
def define_module_inclusion( & block )
|
9
|
+
inclusion_array, extension_array = yield_for_includes_extends( block )
|
10
|
+
ModuleCluster::IncludeSupport.set_includes_for_class_or_module( self, inclusion_array )
|
11
|
+
ModuleCluster::IncludeSupport.set_extends_for_class_or_module( self, extension_array )
|
12
|
+
extend ModuleCluster::IncludeSupport
|
13
|
+
return self
|
14
|
+
end
|
15
|
+
|
16
|
+
#############################
|
17
|
+
# define_module_extension #
|
18
|
+
#############################
|
19
|
+
|
20
|
+
def define_module_extension( & block )
|
21
|
+
inclusion_array, extension_array = yield_for_includes_extends( block )
|
22
|
+
ModuleCluster::ExtendSupport.set_includes_for_class_or_module( self, inclusion_array )
|
23
|
+
ModuleCluster::ExtendSupport.set_extends_for_class_or_module( self, extension_array )
|
24
|
+
extend ModuleCluster::ExtendSupport
|
25
|
+
return self
|
26
|
+
end
|
27
|
+
|
28
|
+
###########################
|
29
|
+
# define_module_cluster #
|
30
|
+
###########################
|
31
|
+
|
32
|
+
def define_module_cluster( & include_extend_block )
|
33
|
+
define_module_inclusion( & include_extend_block )
|
34
|
+
define_module_extension( & include_extend_block )
|
35
|
+
return self
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster::ExtendSupport
|
3
|
+
|
4
|
+
extend ModuleCluster::IncludeExtendSupport
|
5
|
+
|
6
|
+
##############
|
7
|
+
# extended #
|
8
|
+
##############
|
9
|
+
|
10
|
+
def extended( class_or_module )
|
11
|
+
super if defined?( super )
|
12
|
+
module_self = self
|
13
|
+
class_or_module.instance_eval do
|
14
|
+
ModuleCluster::ExtendSupport.includes_for_class_or_module( module_self ).each do |this_module|
|
15
|
+
include this_module
|
16
|
+
end
|
17
|
+
ModuleCluster::ExtendSupport.extends_for_class_or_module( module_self ).each do |this_module|
|
18
|
+
extend this_module
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster::IncludeExtendSupport
|
3
|
+
|
4
|
+
######################################
|
5
|
+
# set_includes_for_class_or_module #
|
6
|
+
######################################
|
7
|
+
|
8
|
+
def set_includes_for_class_or_module( class_or_module, includes )
|
9
|
+
@includes_for_class_or_module ||= Hash.new
|
10
|
+
@includes_for_class_or_module[ class_or_module ] = includes
|
11
|
+
end
|
12
|
+
|
13
|
+
#####################################
|
14
|
+
# set_extends_for_class_or_module #
|
15
|
+
#####################################
|
16
|
+
|
17
|
+
def set_extends_for_class_or_module( class_or_module, extends )
|
18
|
+
@extends_for_class_or_module ||= Hash.new
|
19
|
+
@extends_for_class_or_module[ class_or_module ] = extends
|
20
|
+
end
|
21
|
+
|
22
|
+
############################################
|
23
|
+
# includes_for_class_or_module_inclusion #
|
24
|
+
############################################
|
25
|
+
|
26
|
+
def includes_for_class_or_module( class_or_module )
|
27
|
+
return @includes_for_class_or_module[ class_or_module ] ||= Array.new
|
28
|
+
end
|
29
|
+
|
30
|
+
###########################################
|
31
|
+
# extends_for_class_or_module_extension #
|
32
|
+
###########################################
|
33
|
+
|
34
|
+
def extends_for_class_or_module( class_or_module )
|
35
|
+
return @extends_for_class_or_module[ class_or_module ] ||= Array.new
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster::IncludeSupport
|
3
|
+
|
4
|
+
extend ModuleCluster::IncludeExtendSupport
|
5
|
+
|
6
|
+
##############
|
7
|
+
# included #
|
8
|
+
##############
|
9
|
+
|
10
|
+
def included( class_or_module )
|
11
|
+
super if defined?( super )
|
12
|
+
module_self = self
|
13
|
+
class_or_module.instance_eval do
|
14
|
+
ModuleCluster::IncludeSupport.includes_for_class_or_module( module_self ).each do |this_module|
|
15
|
+
include this_module
|
16
|
+
end
|
17
|
+
ModuleCluster::IncludeSupport.extends_for_class_or_module( module_self ).each do |this_module|
|
18
|
+
extend this_module
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module ModuleCluster
|
3
|
+
|
4
|
+
###########################################################################################################
|
5
|
+
private ###############################################################################################
|
6
|
+
###########################################################################################################
|
7
|
+
|
8
|
+
def yield_for_includes_extends( block )
|
9
|
+
inclusion_array = Array.new
|
10
|
+
extension_array = Array.new
|
11
|
+
returned_includes, returned_extends = block.call( inclusion_array, extension_array )
|
12
|
+
inclusion_array = returned_includes if returned_includes.is_a?( Array )
|
13
|
+
extension_array = returned_extends if returned_extends.is_a?( Array )
|
14
|
+
unless inclusion_array.is_a?( Array ) and extension_array.is_a?( Array )
|
15
|
+
raise 'Expected module inclusion/extension variables to remain Array. Received ' +
|
16
|
+
inclusion_array.inspect + ' for inclusion array, and ' + extension_array.inspect +
|
17
|
+
' for extension array.'
|
18
|
+
end
|
19
|
+
return inclusion_array, extension_array
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/module-cluster.rb'
|
3
|
+
|
4
|
+
describe ModuleCluster::IncludeExtendSupport do
|
5
|
+
|
6
|
+
############################################
|
7
|
+
# set_includes_for_class_or_module #
|
8
|
+
# includes_for_class_or_module_inclusion #
|
9
|
+
############################################
|
10
|
+
|
11
|
+
it 'can set and return includes for a class or module' do
|
12
|
+
module ModuleCluster::IncludeExtendSupport::Mock01
|
13
|
+
extend ModuleCluster::IncludeExtendSupport
|
14
|
+
module MockModule1
|
15
|
+
end
|
16
|
+
module MockModule2
|
17
|
+
end
|
18
|
+
end
|
19
|
+
class ModuleCluster::IncludeExtendSupport::MockClass
|
20
|
+
includes = [ ModuleCluster::IncludeExtendSupport::Mock01::MockModule1,
|
21
|
+
ModuleCluster::IncludeExtendSupport::Mock01::MockModule2 ]
|
22
|
+
ModuleCluster::IncludeExtendSupport::Mock01.set_includes_for_class_or_module( self, includes )
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
###########################################
|
27
|
+
# set_extends_for_class_or_module #
|
28
|
+
# extends_for_class_or_module_extension #
|
29
|
+
###########################################
|
30
|
+
|
31
|
+
it 'can set and return extends for a class or module' do
|
32
|
+
module ModuleCluster::IncludeExtendSupport::Mock02
|
33
|
+
extend ModuleCluster::IncludeExtendSupport
|
34
|
+
module MockModule1
|
35
|
+
end
|
36
|
+
module MockModule2
|
37
|
+
end
|
38
|
+
end
|
39
|
+
class ModuleCluster::IncludeExtendSupport::MockClass
|
40
|
+
includes = [ ModuleCluster::IncludeExtendSupport::Mock02::MockModule1,
|
41
|
+
ModuleCluster::IncludeExtendSupport::Mock02::MockModule2 ]
|
42
|
+
ModuleCluster::IncludeExtendSupport::Mock02.set_includes_for_class_or_module( self, includes )
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,282 @@
|
|
1
|
+
require_relative '../lib/module-cluster.rb'
|
2
|
+
|
3
|
+
describe ModuleCluster do
|
4
|
+
|
5
|
+
#############################
|
6
|
+
# define_module_inclusion #
|
7
|
+
#############################
|
8
|
+
|
9
|
+
it 'can define includes and extends for module inclusion' do
|
10
|
+
module ModuleCluster::MockInclusion01
|
11
|
+
extend ModuleCluster
|
12
|
+
module Mock1
|
13
|
+
end
|
14
|
+
module Mock2
|
15
|
+
end
|
16
|
+
module Mock3
|
17
|
+
end
|
18
|
+
define_module_inclusion do |includes, extends|
|
19
|
+
includes.concat [ Mock1, Mock2 ]
|
20
|
+
extends.concat [ Mock3 ]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
module ModuleCluster::MockInclusion01a
|
24
|
+
ancestors.include?( ModuleCluster::MockInclusion01::Mock1 ).should == false
|
25
|
+
ancestors.include?( ModuleCluster::MockInclusion01::Mock2 ).should == false
|
26
|
+
include ModuleCluster::MockInclusion01
|
27
|
+
ancestors.include?( ModuleCluster::MockInclusion01::Mock1 ).should == true
|
28
|
+
ancestors.include?( ModuleCluster::MockInclusion01::Mock2 ).should == true
|
29
|
+
eigenclass = class << self ; self ; end
|
30
|
+
eigenclass.ancestors.include?( ModuleCluster::MockInclusion01::Mock3 ).should == true
|
31
|
+
end
|
32
|
+
module ModuleCluster::MockInclusion02
|
33
|
+
extend ModuleCluster
|
34
|
+
module Mock1
|
35
|
+
end
|
36
|
+
module Mock2
|
37
|
+
end
|
38
|
+
module Mock3
|
39
|
+
end
|
40
|
+
define_module_inclusion do |includes, extends|
|
41
|
+
includes.concat [ Mock1, Mock2 ]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
module ModuleCluster::MockInclusion02a
|
45
|
+
ancestors.include?( ModuleCluster::MockInclusion02::Mock1 ).should == false
|
46
|
+
ancestors.include?( ModuleCluster::MockInclusion02::Mock2 ).should == false
|
47
|
+
include ModuleCluster::MockInclusion02
|
48
|
+
ancestors.include?( ModuleCluster::MockInclusion02::Mock1 ).should == true
|
49
|
+
ancestors.include?( ModuleCluster::MockInclusion02::Mock2 ).should == true
|
50
|
+
eigenclass = class << self ; self ; end
|
51
|
+
eigenclass.ancestors.include?( ModuleCluster::MockInclusion02::Mock3 ).should == false
|
52
|
+
end
|
53
|
+
module ModuleCluster::MockInclusion03
|
54
|
+
extend ModuleCluster
|
55
|
+
module Mock1
|
56
|
+
end
|
57
|
+
module Mock2
|
58
|
+
end
|
59
|
+
module Mock3
|
60
|
+
end
|
61
|
+
define_module_inclusion do |includes, extends|
|
62
|
+
extends.concat [ Mock3 ]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
module ModuleCluster::MockInclusion03a
|
66
|
+
ancestors.include?( ModuleCluster::MockInclusion03::Mock1 ).should == false
|
67
|
+
ancestors.include?( ModuleCluster::MockInclusion03::Mock2 ).should == false
|
68
|
+
include ModuleCluster::MockInclusion03
|
69
|
+
ancestors.include?( ModuleCluster::MockInclusion03::Mock1 ).should == false
|
70
|
+
ancestors.include?( ModuleCluster::MockInclusion03::Mock2 ).should == false
|
71
|
+
eigenclass = class << self ; self ; end
|
72
|
+
eigenclass.ancestors.include?( ModuleCluster::MockInclusion03::Mock3 ).should == true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#############################
|
77
|
+
# define_module_extension #
|
78
|
+
#############################
|
79
|
+
|
80
|
+
it 'can define includes and extends for module extension' do
|
81
|
+
module ModuleCluster::MockExtension01
|
82
|
+
extend ModuleCluster
|
83
|
+
module Mock1
|
84
|
+
end
|
85
|
+
module Mock2
|
86
|
+
end
|
87
|
+
module Mock3
|
88
|
+
end
|
89
|
+
define_module_extension do |includes, extends|
|
90
|
+
includes.concat [ Mock1, Mock2 ]
|
91
|
+
extends.concat [ Mock3 ]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
module ModuleCluster::MockExtension01a
|
95
|
+
ancestors.include?( ModuleCluster::MockExtension01::Mock1 ).should == false
|
96
|
+
ancestors.include?( ModuleCluster::MockExtension01::Mock2 ).should == false
|
97
|
+
extend ModuleCluster::MockExtension01
|
98
|
+
ancestors.include?( ModuleCluster::MockExtension01::Mock1 ).should == true
|
99
|
+
ancestors.include?( ModuleCluster::MockExtension01::Mock2 ).should == true
|
100
|
+
eigenclass = class << self ; self ; end
|
101
|
+
eigenclass.ancestors.include?( ModuleCluster::MockExtension01::Mock3 ).should == true
|
102
|
+
end
|
103
|
+
module ModuleCluster::MockExtension02
|
104
|
+
extend ModuleCluster
|
105
|
+
module Mock1
|
106
|
+
end
|
107
|
+
module Mock2
|
108
|
+
end
|
109
|
+
module Mock3
|
110
|
+
end
|
111
|
+
define_module_extension do |includes, extends|
|
112
|
+
includes.concat [ Mock1, Mock2 ]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
module ModuleCluster::MockExtension02a
|
116
|
+
ancestors.include?( ModuleCluster::MockExtension02::Mock1 ).should == false
|
117
|
+
ancestors.include?( ModuleCluster::MockExtension02::Mock2 ).should == false
|
118
|
+
extend ModuleCluster::MockExtension02
|
119
|
+
ancestors.include?( ModuleCluster::MockExtension02::Mock1 ).should == true
|
120
|
+
ancestors.include?( ModuleCluster::MockExtension02::Mock2 ).should == true
|
121
|
+
eigenclass = class << self ; self ; end
|
122
|
+
eigenclass.ancestors.include?( ModuleCluster::MockExtension02::Mock3 ).should == false
|
123
|
+
end
|
124
|
+
module ModuleCluster::MockExtension03
|
125
|
+
extend ModuleCluster
|
126
|
+
module Mock1
|
127
|
+
end
|
128
|
+
module Mock2
|
129
|
+
end
|
130
|
+
module Mock3
|
131
|
+
end
|
132
|
+
define_module_extension do |includes, extends|
|
133
|
+
extends.concat [ Mock3 ]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
module ModuleCluster::MockExtension03a
|
137
|
+
ancestors.include?( ModuleCluster::MockExtension03::Mock1 ).should == false
|
138
|
+
ancestors.include?( ModuleCluster::MockExtension03::Mock2 ).should == false
|
139
|
+
extend ModuleCluster::MockExtension03
|
140
|
+
ancestors.include?( ModuleCluster::MockExtension03::Mock1 ).should == false
|
141
|
+
ancestors.include?( ModuleCluster::MockExtension03::Mock2 ).should == false
|
142
|
+
eigenclass = class << self ; self ; end
|
143
|
+
eigenclass.ancestors.include?( ModuleCluster::MockExtension03::Mock3 ).should == true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
###########################
|
148
|
+
# define_module_cluster #
|
149
|
+
###########################
|
150
|
+
|
151
|
+
it 'can define includes and extends for module extension and inclusion' do
|
152
|
+
module ModuleCluster::MockClusterInclusion01
|
153
|
+
extend ModuleCluster
|
154
|
+
module Mock1
|
155
|
+
end
|
156
|
+
module Mock2
|
157
|
+
end
|
158
|
+
module Mock3
|
159
|
+
end
|
160
|
+
define_module_cluster do |includes, extends|
|
161
|
+
includes.concat [ Mock1, Mock2 ]
|
162
|
+
extends.concat [ Mock3 ]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
module ModuleCluster::MockClusterInclusion01a
|
166
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion01::Mock1 ).should == false
|
167
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion01::Mock2 ).should == false
|
168
|
+
include ModuleCluster::MockClusterInclusion01
|
169
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion01::Mock1 ).should == true
|
170
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion01::Mock2 ).should == true
|
171
|
+
eigenclass = class << self ; self ; end
|
172
|
+
eigenclass.ancestors.include?( ModuleCluster::MockClusterInclusion01::Mock3 ).should == true
|
173
|
+
end
|
174
|
+
module ModuleCluster::MockClusterInclusion02
|
175
|
+
extend ModuleCluster
|
176
|
+
module Mock1
|
177
|
+
end
|
178
|
+
module Mock2
|
179
|
+
end
|
180
|
+
module Mock3
|
181
|
+
end
|
182
|
+
define_module_cluster do |includes, extends|
|
183
|
+
includes.concat [ Mock1, Mock2 ]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
module ModuleCluster::MockClusterInclusion02a
|
187
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion02::Mock1 ).should == false
|
188
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion02::Mock2 ).should == false
|
189
|
+
include ModuleCluster::MockClusterInclusion02
|
190
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion02::Mock1 ).should == true
|
191
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion02::Mock2 ).should == true
|
192
|
+
eigenclass = class << self ; self ; end
|
193
|
+
eigenclass.ancestors.include?( ModuleCluster::MockClusterInclusion02::Mock3 ).should == false
|
194
|
+
end
|
195
|
+
module ModuleCluster::MockClusterInclusion03
|
196
|
+
extend ModuleCluster
|
197
|
+
module Mock1
|
198
|
+
end
|
199
|
+
module Mock2
|
200
|
+
end
|
201
|
+
module Mock3
|
202
|
+
end
|
203
|
+
define_module_cluster do |includes, extends|
|
204
|
+
extends.concat [ Mock3 ]
|
205
|
+
end
|
206
|
+
end
|
207
|
+
module ModuleCluster::MockClusterInclusion03a
|
208
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion03::Mock1 ).should == false
|
209
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion03::Mock2 ).should == false
|
210
|
+
include ModuleCluster::MockClusterInclusion03
|
211
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion03::Mock1 ).should == false
|
212
|
+
ancestors.include?( ModuleCluster::MockClusterInclusion03::Mock2 ).should == false
|
213
|
+
eigenclass = class << self ; self ; end
|
214
|
+
eigenclass.ancestors.include?( ModuleCluster::MockClusterInclusion03::Mock3 ).should == true
|
215
|
+
end
|
216
|
+
module ModuleCluster::MockClusterExtension01
|
217
|
+
extend ModuleCluster
|
218
|
+
module Mock1
|
219
|
+
end
|
220
|
+
module Mock2
|
221
|
+
end
|
222
|
+
module Mock3
|
223
|
+
end
|
224
|
+
define_module_cluster do |includes, extends|
|
225
|
+
includes.concat [ Mock1, Mock2 ]
|
226
|
+
extends.concat [ Mock3 ]
|
227
|
+
end
|
228
|
+
end
|
229
|
+
module ModuleCluster::MockClusterExtension01a
|
230
|
+
ancestors.include?( ModuleCluster::MockClusterExtension01::Mock1 ).should == false
|
231
|
+
ancestors.include?( ModuleCluster::MockClusterExtension01::Mock2 ).should == false
|
232
|
+
extend ModuleCluster::MockClusterExtension01
|
233
|
+
ancestors.include?( ModuleCluster::MockClusterExtension01::Mock1 ).should == true
|
234
|
+
ancestors.include?( ModuleCluster::MockClusterExtension01::Mock2 ).should == true
|
235
|
+
eigenclass = class << self ; self ; end
|
236
|
+
eigenclass.ancestors.include?( ModuleCluster::MockClusterExtension01::Mock3 ).should == true
|
237
|
+
end
|
238
|
+
module ModuleCluster::MockClusterExtension02
|
239
|
+
extend ModuleCluster
|
240
|
+
module Mock1
|
241
|
+
end
|
242
|
+
module Mock2
|
243
|
+
end
|
244
|
+
module Mock3
|
245
|
+
end
|
246
|
+
define_module_cluster do |includes, extends|
|
247
|
+
includes.concat [ Mock1, Mock2 ]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
module ModuleCluster::MockClusterExtension02a
|
251
|
+
ancestors.include?( ModuleCluster::MockClusterExtension02::Mock1 ).should == false
|
252
|
+
ancestors.include?( ModuleCluster::MockClusterExtension02::Mock2 ).should == false
|
253
|
+
extend ModuleCluster::MockClusterExtension02
|
254
|
+
ancestors.include?( ModuleCluster::MockClusterExtension02::Mock1 ).should == true
|
255
|
+
ancestors.include?( ModuleCluster::MockClusterExtension02::Mock2 ).should == true
|
256
|
+
eigenclass = class << self ; self ; end
|
257
|
+
eigenclass.ancestors.include?( ModuleCluster::MockClusterExtension02::Mock3 ).should == false
|
258
|
+
end
|
259
|
+
module ModuleCluster::MockClusterExtension03
|
260
|
+
extend ModuleCluster
|
261
|
+
module Mock1
|
262
|
+
end
|
263
|
+
module Mock2
|
264
|
+
end
|
265
|
+
module Mock3
|
266
|
+
end
|
267
|
+
define_module_cluster do |includes, extends|
|
268
|
+
extends.concat [ Mock3 ]
|
269
|
+
end
|
270
|
+
end
|
271
|
+
module ModuleCluster::MockClusterExtension03a
|
272
|
+
ancestors.include?( ModuleCluster::MockClusterExtension03::Mock1 ).should == false
|
273
|
+
ancestors.include?( ModuleCluster::MockClusterExtension03::Mock2 ).should == false
|
274
|
+
extend ModuleCluster::MockClusterExtension03
|
275
|
+
ancestors.include?( ModuleCluster::MockClusterExtension03::Mock1 ).should == false
|
276
|
+
ancestors.include?( ModuleCluster::MockClusterExtension03::Mock2 ).should == false
|
277
|
+
eigenclass = class << self ; self ; end
|
278
|
+
eigenclass.ancestors.include?( ModuleCluster::MockClusterExtension03::Mock3 ).should == true
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: module-cluster
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Asher
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-07-21 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Provides :define_module_inclusion, :define_module_extension, and :define_module_cluster.
|
22
|
+
email: asher@ridiculouspower.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/module-cluster/_private_/ModuleCluster.rb
|
31
|
+
- lib/module-cluster/ModuleCluster/ExtendSupport.rb
|
32
|
+
- lib/module-cluster/ModuleCluster/IncludeExtendSupport.rb
|
33
|
+
- lib/module-cluster/ModuleCluster/IncludeSupport.rb
|
34
|
+
- lib/module-cluster/ModuleCluster.rb
|
35
|
+
- lib/module-cluster.rb
|
36
|
+
- spec/ModuleCluster/IncludeExtendSupport_spec.rb
|
37
|
+
- spec/ModuleCluster_spec.rb
|
38
|
+
- README.md
|
39
|
+
- README.rdoc
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://rubygems.org/gems/module-cluster
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: module-cluster
|
68
|
+
rubygems_version: 1.3.7
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: "Adds methods for defining module clusters using #included and #extended."
|
72
|
+
test_files: []
|
73
|
+
|