module-cluster 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/README.md +4 -4
  2. data/README.rdoc +4 -4
  3. data/lib/module-cluster.rb +19 -10
  4. data/lib/module-cluster/ModuleCluster.rb +1 -1
  5. data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +3 -3
  6. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +4 -4
  7. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +4 -4
  8. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +4 -4
  9. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrSubclass.rb +29 -0
  10. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrSubclass.rb +22 -0
  11. data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +3 -3
  12. data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +3 -3
  13. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +4 -4
  14. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrSubclass.rb +22 -0
  15. data/lib/module-cluster/ModuleCluster/Define/Block/Subclass.rb +32 -5
  16. data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +3 -3
  17. data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +3 -3
  18. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +3 -3
  19. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +3 -3
  20. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +3 -3
  21. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +3 -3
  22. data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +3 -3
  23. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +3 -3
  24. data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +3 -3
  25. data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +3 -3
  26. data/lib/module-cluster/ModuleCluster/Define/Status.rb +4 -4
  27. data/lib/module-cluster/ModuleCluster/Suspend/WithoutHooks.rb +1 -1
  28. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +1 -1
  29. data/lib/module-cluster/_private_/ModuleCluster/ExtendForCascade.rb +1 -1
  30. data/lib/module-cluster/_private_/ModuleCluster/ExtendForCascade/Subclass.rb +55 -8
  31. data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +36 -36
  32. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +36 -36
  33. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrSubclass_spec.rb +55 -0
  34. data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +36 -36
  35. data/spec/ModuleCluster/Define/Block/ClassOrSubclass_spec.rb +54 -0
  36. data/spec/ModuleCluster/Define/Block/Class_spec.rb +36 -36
  37. data/spec/ModuleCluster/Define/Block/Instance_spec.rb +12 -12
  38. data/spec/ModuleCluster/Define/Block/ModuleOrSubclass_spec.rb +53 -0
  39. data/spec/ModuleCluster/Define/Block/Module_spec.rb +36 -36
  40. data/spec/ModuleCluster/Define/Block/Subclass_spec.rb +39 -9
  41. data/spec/ModuleCluster/Define/ClassCluster_spec.rb +71 -71
  42. data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +60 -60
  43. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +72 -72
  44. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +72 -72
  45. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +68 -68
  46. data/spec/ModuleCluster/Define/Cluster_spec.rb +71 -71
  47. data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +8 -8
  48. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +71 -71
  49. data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +71 -71
  50. data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +60 -60
  51. data/spec/ModuleCluster/Suspend/Hooks_spec.rb +14 -14
  52. data/spec/ModuleCluster/Suspend/WithoutHooks_spec.rb +14 -14
  53. data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +6 -6
  54. data/spec/_private_/ModuleCluster/ClusterStack/Suspend_spec.rb +8 -8
  55. metadata +33 -29
data/README.md CHANGED
@@ -20,7 +20,7 @@ Simply:
20
20
 
21
21
  ```ruby
22
22
  module SomeModule
23
- extend 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
- extend 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
- extend ModuleCluster
42
+ extend ::ModuleCluster
43
43
  include_also_includes( SomeOtherModule ) do
44
44
  AnotherModule
45
45
  end
@@ -50,7 +50,7 @@ Blocks can be used to return dynamically-determined modules at runtime.
50
50
 
51
51
  ```ruby
52
52
  module SomeModule
53
- extend ModuleCluster
53
+ extend ::ModuleCluster
54
54
  include_or_extend_cascades_prepend_extends do
55
55
  method_that_returns_one_or_more_modules
56
56
  end
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
- extend 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
- extend 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
- extend ModuleCluster
37
+ extend ::ModuleCluster
38
38
  include_also_includes( SomeOtherModule ) do
39
39
  AnotherModule
40
40
  end
@@ -43,7 +43,7 @@ end
43
43
  Blocks can be used to return dynamically-determined modules at runtime.
44
44
 
45
45
  module SomeModule
46
- extend ModuleCluster
46
+ extend ::ModuleCluster
47
47
  include_or_extend_cascades_prepend_extends do
48
48
  method_that_returns_one_or_more_modules
49
49
  end
@@ -36,12 +36,18 @@ module ModuleCluster
36
36
  end
37
37
  module ClassOrInstance
38
38
  end
39
+ module ClassOrSubclass
40
+ end
41
+ module ClassOrModuleOrSubclass
42
+ end
39
43
  module Instance
40
44
  end
41
45
  module Module
42
46
  end
43
47
  module ModuleOrInstance
44
48
  end
49
+ module ModuleOrSubclass
50
+ end
45
51
  end
46
52
  module ClusterStack
47
53
  end
@@ -105,16 +111,6 @@ require_relative 'module-cluster/ModuleCluster/Suspend/Hooks.rb'
105
111
  require_relative 'module-cluster/ModuleCluster/Suspend/WithoutHooks.rb'
106
112
  require_relative 'module-cluster/ModuleCluster/Suspend.rb'
107
113
 
108
- require_relative 'module-cluster/ModuleCluster/Define/Block/Class.rb'
109
- require_relative 'module-cluster/ModuleCluster/Define/Block/Subclass.rb'
110
- require_relative 'module-cluster/ModuleCluster/Define/Block/Instance.rb'
111
- require_relative 'module-cluster/ModuleCluster/Define/Block/Module.rb'
112
- require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb'
113
- require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb'
114
- require_relative 'module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb'
115
- require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb'
116
- require_relative 'module-cluster/ModuleCluster/Define/Block.rb'
117
-
118
114
  require_relative 'module-cluster/ModuleCluster/Define/Cluster.rb'
119
115
  require_relative 'module-cluster/ModuleCluster/Define/ModuleCluster.rb'
120
116
  require_relative 'module-cluster/ModuleCluster/Define/ClassCluster.rb'
@@ -126,6 +122,19 @@ require_relative 'module-cluster/ModuleCluster/Define/ClusterCascades.rb'
126
122
  require_relative 'module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb'
127
123
  require_relative 'module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb'
128
124
 
125
+ require_relative 'module-cluster/ModuleCluster/Define/Block/Class.rb'
126
+ require_relative 'module-cluster/ModuleCluster/Define/Block/Instance.rb'
127
+ require_relative 'module-cluster/ModuleCluster/Define/Block/Module.rb'
128
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb'
129
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb'
130
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb'
131
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb'
132
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrSubclass.rb'
133
+ require_relative 'module-cluster/ModuleCluster/Define/Block/Subclass.rb'
134
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ModuleOrSubclass.rb'
135
+ require_relative 'module-cluster/ModuleCluster/Define/Block/ClassOrSubclass.rb'
136
+ require_relative 'module-cluster/ModuleCluster/Define/Block.rb'
137
+
129
138
  require_relative 'module-cluster/ModuleCluster/Define/Deprecated.rb'
130
139
 
131
140
  require_relative 'module-cluster/ModuleCluster/Define.rb'
@@ -1,7 +1,7 @@
1
1
 
2
2
  module ModuleCluster
3
3
 
4
- extend ModuleCluster::ExtendForCascade
4
+ extend ::ModuleCluster::ExtendForCascade
5
5
 
6
6
  include Define
7
7
  include Suspend
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::Class
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ############################
10
10
  # self.should_run_block? #
@@ -1,11 +1,11 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::ClassOrInstance
3
3
 
4
- include ModuleCluster::Define::Block::Class
5
- include ModuleCluster::Define::Block::Instance
6
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::Define::Block::Class
5
+ include ::ModuleCluster::Define::Block::Instance
6
+ include ::ModuleCluster::Suspend::WithoutHooks
7
7
 
8
- extend ModuleCluster::ExtendForCascade
8
+ extend ::ModuleCluster::ExtendForCascade
9
9
 
10
10
  ##############################
11
11
  # class_or_instance_extend #
@@ -1,11 +1,11 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::ClassOrModule
3
3
 
4
- include ModuleCluster::Define::Block::Class
5
- include ModuleCluster::Define::Block::Module
6
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::Define::Block::Class
5
+ include ::ModuleCluster::Define::Block::Module
6
+ include ::ModuleCluster::Suspend::WithoutHooks
7
7
 
8
- extend ModuleCluster::ExtendForCascade
8
+ extend ::ModuleCluster::ExtendForCascade
9
9
 
10
10
  #############################
11
11
  # class_or_module_include #
@@ -1,11 +1,11 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::ClassOrModuleOrInstance
3
3
 
4
- include ModuleCluster::Define::Block::ClassOrModule
5
- include ModuleCluster::Define::Block::Instance
6
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::Define::Block::ClassOrModule
5
+ include ::ModuleCluster::Define::Block::Instance
6
+ include ::ModuleCluster::Suspend::WithoutHooks
7
7
 
8
- extend ModuleCluster::ExtendForCascade
8
+ extend ::ModuleCluster::ExtendForCascade
9
9
 
10
10
  ########################################
11
11
  # class_or_module_or_instance_extend #
@@ -0,0 +1,29 @@
1
+
2
+ module ModuleCluster::Define::Block::ClassOrModuleOrSubclass
3
+
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Define::Block::ClassOrModule
6
+ include ::ModuleCluster::Suspend::WithoutHooks
7
+
8
+ extend ::ModuleCluster::ExtendForCascade::Subclass
9
+ extend ::ModuleCluster::ExtendForCascade
10
+
11
+ ############################
12
+ # self.should_run_block? #
13
+ ############################
14
+
15
+ def self.should_run_block?( hooked_instance )
16
+ return hooked_instance.is_a?( Module )
17
+ end
18
+
19
+ #########################################
20
+ # class_or_module_include_or_subclass #
21
+ #########################################
22
+
23
+ def class_or_module_include_or_subclass( & runtime_block )
24
+ class_or_module_set = class_or_module_include( & runtime_block )
25
+ subclass_set = cluster_stack.subclass( ModuleCluster::Define::Block::ClassOrModuleOrSubclass, runtime_block )
26
+ return ModuleCluster::ClusterStack::Set::MultiSetProxy.new( class_or_module_set, subclass_set )
27
+ end
28
+
29
+ end
@@ -0,0 +1,22 @@
1
+
2
+ module ModuleCluster::Define::Block::ClassOrSubclass
3
+
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Define::Block::Class
6
+ include ::ModuleCluster::Define::Block::Subclass
7
+ include ::ModuleCluster::Suspend::WithoutHooks
8
+
9
+ extend ::ModuleCluster::ExtendForCascade::Subclass
10
+ extend ::ModuleCluster::ExtendForCascade
11
+
12
+ ###############################
13
+ # class_include_or_subclass #
14
+ ###############################
15
+
16
+ def class_include_or_subclass( & runtime_block )
17
+ class_set = class_include( & runtime_block )
18
+ subclass_set = subclass( & runtime_block )
19
+ return ModuleCluster::ClusterStack::Set::MultiSetProxy.new( class_set, subclass_set )
20
+ end
21
+
22
+ end
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::Instance
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ############################
10
10
  # self.should_run_block? #
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::Module
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ############################
10
10
  # self.should_run_block? #
@@ -1,11 +1,11 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::ModuleOrInstance
3
3
 
4
- include ModuleCluster::Define::Block::Module
5
- include ModuleCluster::Define::Block::Instance
6
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::Define::Block::Module
5
+ include ::ModuleCluster::Define::Block::Instance
6
+ include ::ModuleCluster::Suspend::WithoutHooks
7
7
 
8
- extend ModuleCluster::ExtendForCascade
8
+ extend ::ModuleCluster::ExtendForCascade
9
9
 
10
10
  ###############################
11
11
  # module_or_instance_extend #
@@ -0,0 +1,22 @@
1
+
2
+ module ModuleCluster::Define::Block::ModuleOrSubclass
3
+
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Define::Block::Module
6
+ include ::ModuleCluster::Define::Block::Subclass
7
+ include ::ModuleCluster::Suspend::WithoutHooks
8
+
9
+ extend ::ModuleCluster::ExtendForCascade::Subclass
10
+ extend ::ModuleCluster::ExtendForCascade
11
+
12
+ ################################
13
+ # module_include_or_subclass #
14
+ ################################
15
+
16
+ def module_include_or_subclass( & runtime_block )
17
+ module_set = module_include( & runtime_block )
18
+ subclass_set = subclass( & runtime_block )
19
+ return ModuleCluster::ClusterStack::Set::MultiSetProxy.new( module_set, subclass_set )
20
+ end
21
+
22
+ end
@@ -1,17 +1,44 @@
1
1
 
2
2
  module ModuleCluster::Define::Block::Subclass
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
+ extend ::ModuleCluster::Define::Block::Module
7
+
8
+ # module_extend do |module_instance|
9
+ # module_instance.module_eval do
10
+ # extend ::ModuleCluster::Define::Block::Class
11
+ # class_include do |class_instance|
12
+ # end
13
+ # end
14
+ # end
15
+
16
+ extend ::ModuleCluster::ExtendForCascade::Subclass
6
17
 
7
- extend ModuleCluster::ExtendForCascade::Subclass
8
-
9
18
  ############################
10
19
  # self.should_run_block? #
11
20
  ############################
12
21
 
13
22
  def self.should_run_block?( hooked_instance )
14
- return hooked_instance.is_a?( Class )
23
+
24
+ should_run_block = false
25
+
26
+ if hooked_instance.is_a?( Module )
27
+
28
+ if hooked_instance.is_a?( Class )
29
+
30
+ # subclass instance
31
+ if hooked_instance.ancestors[ 1 ].is_a?( Class )
32
+ should_run_block = true
33
+ end
34
+ # class instance - don't run
35
+ end
36
+ # module instance - don't run
37
+
38
+ end
39
+
40
+ return should_run_block
41
+
15
42
  end
16
43
 
17
44
  ##############
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::ClassCluster
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ####################################
10
10
  # self.should_include_or_extend? #
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::ClassOrInstanceCluster
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ####################################
10
10
  # self.should_include_or_extend? #
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::Cluster
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ####################################
10
10
  # self.should_include_or_extend? #
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::ClusterCascades
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ####################################
10
10
  # self.should_include_or_extend? #
@@ -1,10 +1,10 @@
1
1
 
2
2
  module ModuleCluster::Define::ClusterCascadesToClass
3
3
 
4
- include ModuleCluster::CascadeFeatures::ClusterStack
5
- include ModuleCluster::Suspend::WithoutHooks
4
+ include ::ModuleCluster::CascadeFeatures::ClusterStack
5
+ include ::ModuleCluster::Suspend::WithoutHooks
6
6
 
7
- extend ModuleCluster::ExtendForCascade
7
+ extend ::ModuleCluster::ExtendForCascade
8
8
 
9
9
  ####################################
10
10
  # self.should_include_or_extend? #