module-cluster 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,7 +20,7 @@ Simply:
20
20
 
21
21
  ```ruby
22
22
  module SomeModule
23
- include ModuleCluster
23
+ extend ModuleCluster
24
24
  end
25
25
  ```
26
26
 
@@ -30,7 +30,7 @@ For example:
30
30
 
31
31
  ```ruby
32
32
  module SomeModule
33
- include ModuleCluster
33
+ extend ModuleCluster
34
34
  include_also_includes( SomeOtherModule )
35
35
  end
36
36
  ```
@@ -39,7 +39,7 @@ Additionally, all methods accept a block that returns one or more modules; the m
39
39
 
40
40
  ```ruby
41
41
  module SomeModule
42
- include ModuleCluster
42
+ extend ModuleCluster
43
43
  include_also_includes( SomeOtherModule ) do
44
44
  AnotherModule
45
45
  end
@@ -49,8 +49,21 @@ end
49
49
  Blocks can be used to return dynamically-determined modules at runtime.
50
50
 
51
51
  ```ruby
52
- class_or_module.include_or_extend_cascades_prepending_extends do
53
- method_that_returns_one_or_more_modules
52
+ module SomeModule
53
+ extend ModuleCluster
54
+ include_or_extend_cascades_prepending_extends do
55
+ method_that_returns_one_or_more_modules
56
+ end
57
+ end
58
+ ```
59
+
60
+ Block methods can be used for nesting declarations, for instance to apply cascades only after first module/class:
61
+
62
+ ```ruby
63
+ prepend_module_include do |class_or_module|
64
+ class_or_module.include_or_extend_cascades_prepending_extends do
65
+ method_that_returns_one_or_more_modules
66
+ end
54
67
  end
55
68
  ```
56
69
 
@@ -142,15 +155,26 @@ Cascade to module methods (does not cascade to classes):
142
155
  * include_or_extend_cascades_to_module_prepending_extends
143
156
  * include_or_extend_cascades_to_module_prepending_includes_and_extends
144
157
 
145
- Block methods (used for nesting declarations, for instance to apply cascades only after first module/class):
146
-
147
- ```ruby
148
- prepend_module_include do |class_or_module|
149
- class_or_module.include_or_extend_cascades_prepending_extends do
150
- method_that_returns_one_or_more_modules
151
- end
152
- end
153
- ```
158
+ Block methods:
159
+
160
+ * module_include
161
+ * module_extend
162
+ * module_include_or_extend
163
+ * prepend_module_include
164
+ * prepend_module_extend
165
+ * prepend_module_include_or_extend
166
+ * class_include
167
+ * class_extend
168
+ * class_include_or_extend
169
+ * prepend_class_include
170
+ * prepend_class_extend
171
+ * prepend_class_include_or_extend
172
+ * class_or_module_include
173
+ * class_or_module_extend
174
+ * class_or_module_include_or_extend
175
+ * prepend_class_or_module_include
176
+ * prepend_class_or_module_extend
177
+ * prepend_class_or_module_include_or_extend
154
178
 
155
179
  # License #
156
180
 
data/README.rdoc CHANGED
@@ -19,7 +19,7 @@ Provides methods for clustering modules so that when the main module is included
19
19
  Simply:
20
20
 
21
21
  module SomeModule
22
- include ModuleCluster
22
+ extend ModuleCluster
23
23
  end
24
24
 
25
25
  Definition methods accept modules as arguments.
@@ -27,14 +27,14 @@ Definition methods accept modules as arguments.
27
27
  For example:
28
28
 
29
29
  module SomeModule
30
- include ModuleCluster
30
+ extend ModuleCluster
31
31
  include_also_includes( SomeOtherModule )
32
32
  end
33
33
 
34
34
  Additionally, all methods accept a block that returns one or more modules; the modules will be added *after* any modules specified in the parameters:
35
35
 
36
36
  module SomeModule
37
- include ModuleCluster
37
+ extend ModuleCluster
38
38
  include_also_includes( SomeOtherModule ) do
39
39
  AnotherModule
40
40
  end
@@ -42,8 +42,19 @@ end
42
42
 
43
43
  Blocks can be used to return dynamically-determined modules at runtime.
44
44
 
45
- class_or_module.include_or_extend_cascades_prepending_extends do
46
- method_that_returns_one_or_more_modules
45
+ module SomeModule
46
+ extend ModuleCluster
47
+ include_or_extend_cascades_prepending_extends do
48
+ method_that_returns_one_or_more_modules
49
+ end
50
+ end
51
+
52
+ Block methods can be used for nesting declarations, for instance to apply cascades only after first module/class:
53
+
54
+ prepend_module_include do |class_or_module|
55
+ class_or_module.include_or_extend_cascades_prepending_extends do
56
+ method_that_returns_one_or_more_modules
57
+ end
47
58
  end
48
59
 
49
60
  Calls to the various functions are cumulative and stack in the order called. This permits multiple calls, whether subsequently or otherwise.
@@ -134,13 +145,26 @@ Cascade to module methods (does not cascade to classes):
134
145
  * include_or_extend_cascades_to_module_prepending_extends
135
146
  * include_or_extend_cascades_to_module_prepending_includes_and_extends
136
147
 
137
- Block methods (used for nesting declarations, for instance to apply cascades only after first module/class, or for dynamic declarations):
138
-
139
- prepend_module_include do |class_or_module|
140
- class_or_module.include_or_extend_cascades_prepending_extends do
141
- method_that_returns_one_or_more_modules
142
- end
143
- end
148
+ Block methods:
149
+
150
+ * module_include
151
+ * module_extend
152
+ * module_include_or_extend
153
+ * prepend_module_include
154
+ * prepend_module_extend
155
+ * prepend_module_include_or_extend
156
+ * class_include
157
+ * class_extend
158
+ * class_include_or_extend
159
+ * prepend_class_include
160
+ * prepend_class_extend
161
+ * prepend_class_include_or_extend
162
+ * class_or_module_include
163
+ * class_or_module_extend
164
+ * class_or_module_include_or_extend
165
+ * prepend_class_or_module_include
166
+ * prepend_class_or_module_extend
167
+ * prepend_class_or_module_include_or_extend
144
168
 
145
169
  == License
146
170
 
@@ -70,7 +70,7 @@ module ModuleCluster::CascadeFeatures
70
70
  block )
71
71
  cascades[ this_set.dependency_module ] ||= Hash.new
72
72
  cascades[ this_set.dependency_module ][ this_set.method ] ||= Array.new
73
- cascades[ this_set.dependency_module ][ this_set.method ].concat( runtime_set )
73
+ cascades[ this_set.dependency_module ][ this_set.method ].concat( runtime_set )
74
74
  end
75
75
  # get includes/extends
76
76
  case this_set.include_or_extend
@@ -112,16 +112,33 @@ module ModuleCluster::CascadeFeatures
112
112
  ###########################
113
113
 
114
114
  def self.cascade_features( class_or_module, cascade_struct )
115
+
116
+ if class_or_module.is_a?( Module )
115
117
 
116
- class_or_module.module_eval do
117
- include( *cascade_struct.includes.reverse ) unless cascade_struct.includes.empty?
118
- extend( *cascade_struct.extends.reverse ) unless cascade_struct.extends.empty?
119
- end
118
+ class_or_module.module_eval do
119
+ include( *cascade_struct.includes.reverse ) unless cascade_struct.includes.empty?
120
+ extend( *cascade_struct.extends.reverse ) unless cascade_struct.extends.empty?
121
+ end
120
122
 
121
- cascade_struct.cascades.each do |this_dependency_module, this_method_and_module_set|
122
- this_method_and_module_set.each do |this_method, this_module_set|
123
- this_dependency_module.perform_cascades( class_or_module, this_method, this_module_set )
123
+ cascade_struct.cascades.each do |this_dependency_module, this_method_and_module_set|
124
+ this_method_and_module_set.each do |this_method, this_module_set|
125
+ this_dependency_module.perform_cascades( class_or_module, this_method, this_module_set )
126
+ end
127
+ end
128
+
129
+ else
130
+
131
+ class_or_module.instance_eval do
132
+ extend( *cascade_struct.includes.reverse ) unless cascade_struct.includes.empty?
133
+ extend( *cascade_struct.extends.reverse ) unless cascade_struct.extends.empty?
134
+ end
135
+
136
+ cascade_struct.cascades.each do |this_dependency_module, this_method_and_module_set|
137
+ this_method_and_module_set.each do |this_method, this_module_set|
138
+ this_dependency_module.perform_cascades( class_or_module, :extend, this_module_set )
139
+ end
124
140
  end
141
+
125
142
  end
126
143
 
127
144
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: module-cluster
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 3
8
- - 4
9
- version: 1.3.4
4
+ prerelease:
5
+ version: 1.3.5
10
6
  platform: ruby
11
7
  authors:
12
8
  - Asher
@@ -14,8 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-08-06 00:00:00 -04:00
18
- default_executable:
13
+ date: 2011-08-25 00:00:00 Z
19
14
  dependencies: []
20
15
 
21
16
  description: "Provides methods for clustering modules so that when the main module is included other modules are also included or extended, either before or after the main module. There are currently three variants: cluster, cascade, cascade to class. Cluster causes the next module to be affected. Cascade causes all subsequent modules to be affected. Cascade to class causes the first including/extending class to be affected, but not any modules prior to it (although the effects will cascade through those unaffected modules)."
@@ -56,7 +51,6 @@ files:
56
51
  - spec/ModuleCluster_spec.rb
57
52
  - README.md
58
53
  - README.rdoc
59
- has_rdoc: true
60
54
  homepage: http://rubygems.org/gems/module-cluster
61
55
  licenses: []
62
56
 
@@ -70,21 +64,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
64
  requirements:
71
65
  - - ">="
72
66
  - !ruby/object:Gem::Version
73
- segments:
74
- - 0
75
67
  version: "0"
76
68
  required_rubygems_version: !ruby/object:Gem::Requirement
77
69
  none: false
78
70
  requirements:
79
71
  - - ">="
80
72
  - !ruby/object:Gem::Version
81
- segments:
82
- - 0
83
73
  version: "0"
84
74
  requirements: []
85
75
 
86
76
  rubyforge_project: module-cluster
87
- rubygems_version: 1.3.7
77
+ rubygems_version: 1.8.7
88
78
  signing_key:
89
79
  specification_version: 3
90
80
  summary: "Adds methods for defining module clusters using #included, #extended, #append_features, and #extend_object."