hospodar 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/hospodar/builder/helpers.rb +1 -1
- data/lib/hospodar/builder/strategies/translate.rb +1 -1
- data/lib/hospodar/dsl.rb +5 -5
- data/lib/hospodar/inheritance_helpers.rb +6 -6
- data/lib/hospodar/module_builder.rb +7 -7
- data/lib/hospodar/subclassing_helpers.rb +3 -3
- data/lib/hospodar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56564d3ce243d1aff5765e7822630f0601ee1fa844fb85ccbe270acaafb45594
|
4
|
+
data.tar.gz: eb73b40ef61ce7c0cbee1a8f0fb2fb7df9f4cfcd272f6f4cebcdc421992ad85f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d089b21733e1ff3f7c8059b5b469c235599e9c3258e2269ba6af43ca25f0f395bd84d4f32fa2688fb1da2c02e03b883232cf49ba7a374f326201582972a31484
|
7
|
+
data.tar.gz: 00665c490d08f703efc781bb12f22c6c2c33231ac84bb8ffe9772388df6d82f6d5ba5680f64ff330463b749bf0afb4175911470ab11e8542cc8eac0e61b8140b
|
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ module Hospodar
|
|
4
4
|
module Builder
|
5
5
|
# Helps determine object creation procedure for given attributes
|
6
6
|
module Helpers
|
7
|
-
def
|
7
|
+
def hospodar_assembler_new_instance(group, step, *_attrs)
|
8
8
|
return public_send(:"build_#{step}") if %i[flat wrap nest].include?(group)
|
9
9
|
|
10
10
|
mod = included_modules.detect { |m| m.respond_to?(:component_name) && m.component_name == group }
|
@@ -21,7 +21,7 @@ module Hospodar
|
|
21
21
|
ExecutionPlanMatrix = Struct.new(:collection) do
|
22
22
|
def with_creation_procs(factory)
|
23
23
|
self.collection = collection.map do |group, title|
|
24
|
-
[group, title, factory.
|
24
|
+
[group, title, factory.hospodar_assembler_new_instance(group, title)]
|
25
25
|
end
|
26
26
|
self
|
27
27
|
end
|
data/lib/hospodar/dsl.rb
CHANGED
@@ -7,7 +7,7 @@ module Hospodar
|
|
7
7
|
mod = self
|
8
8
|
receiver.define_singleton_method(mod.store_method_name(title)) do |klass|
|
9
9
|
base_class = public_send(:"#{mod.components_storage_name}")[title]
|
10
|
-
|
10
|
+
hospodar_check_inheritance!(klass, base_class)
|
11
11
|
send(mod.simple_store_method_name(title), klass)
|
12
12
|
end
|
13
13
|
end
|
@@ -26,12 +26,12 @@ module Hospodar
|
|
26
26
|
define_method(mod.activation_method_name) do |title, base_class, klass, init = nil, &block|
|
27
27
|
raise(ArgumentError, 'please provide a block or class') if klass.nil? && block.nil?
|
28
28
|
|
29
|
-
|
29
|
+
hospodar_check_inheritance!(klass, base_class)
|
30
30
|
|
31
31
|
target_class = klass || base_class
|
32
32
|
|
33
|
-
patched_class =
|
34
|
-
|
33
|
+
patched_class = hospodar_patch_class(target_class, &block)
|
34
|
+
hospodar_define_init(patched_class, &init)
|
35
35
|
public_send(mod.store_method_name(title), patched_class)
|
36
36
|
end
|
37
37
|
end
|
@@ -63,7 +63,7 @@ module Hospodar
|
|
63
63
|
private :"write_#{reader_name}"
|
64
64
|
end
|
65
65
|
klass = base_class || mod.default_base_class || Class.new(Object)
|
66
|
-
|
66
|
+
hospodar_define_init(klass, &(init || mod.default_init))
|
67
67
|
mod.define_component_store_method(self, title)
|
68
68
|
mod.define_component_simple_store_method(self, title)
|
69
69
|
send(mod.simple_store_method_name(title), klass)
|
@@ -9,17 +9,17 @@ module Hospodar
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def copy_superclass_configuration
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
hospodar_included_modules.each do |factory|
|
13
|
+
hospodar_copy_configuration_for_unit(factory.component_name)
|
14
|
+
hospodar_activate_components_for_factory(factory)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def hospodar_included_modules
|
19
19
|
Hospodar.registered_modules & included_modules
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def hospodar_copy_configuration_for_unit(component_name)
|
23
23
|
readers_regexp = Regexp.new("\\w+_#{component_name}_class\\z")
|
24
24
|
superclass.public_methods.grep(readers_regexp).each do |reader_method|
|
25
25
|
klass = superclass.public_send(reader_method)
|
@@ -27,7 +27,7 @@ module Hospodar
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def hospodar_activate_components_for_factory(factory)
|
31
31
|
superclass.public_send(factory.components_storage_name.to_s).each do |component, klass|
|
32
32
|
public_send(factory.store_method_name(component), klass)
|
33
33
|
end
|
@@ -21,12 +21,12 @@ module Hospodar
|
|
21
21
|
def extended(receiver)
|
22
22
|
receiver.extend SubclassingHelpers
|
23
23
|
receiver.extend InheritanceHelpers
|
24
|
-
receiver.private_class_method :
|
25
|
-
receiver.private_class_method :
|
26
|
-
receiver.private_class_method :
|
27
|
-
receiver.private_class_method :
|
28
|
-
receiver.private_class_method :
|
29
|
-
receiver.private_class_method :
|
24
|
+
receiver.private_class_method :hospodar_define_init
|
25
|
+
receiver.private_class_method :hospodar_patch_class
|
26
|
+
receiver.private_class_method :hospodar_check_inheritance!
|
27
|
+
receiver.private_class_method :hospodar_included_modules
|
28
|
+
receiver.private_class_method :hospodar_copy_configuration_for_unit
|
29
|
+
receiver.private_class_method :hospodar_activate_components_for_factory
|
30
30
|
end
|
31
31
|
|
32
32
|
def hash
|
@@ -36,7 +36,7 @@ module Hospodar
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def components_storage_name(title = components_name)
|
39
|
-
:"
|
39
|
+
:"hospodar_#{title}"
|
40
40
|
end
|
41
41
|
|
42
42
|
def simple_store_method_name(name)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Hospodar
|
4
4
|
# Component-level logic for patching base classes
|
5
5
|
module SubclassingHelpers
|
6
|
-
def
|
6
|
+
def hospodar_define_init(klass, &init)
|
7
7
|
if init
|
8
8
|
klass.define_singleton_method(:__ms_init__, &init)
|
9
9
|
elsif klass.superclass.respond_to?(:__ms_init__)
|
@@ -15,13 +15,13 @@ module Hospodar
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def hospodar_patch_class(base_class, &block)
|
19
19
|
return base_class unless block
|
20
20
|
|
21
21
|
Class.new(base_class, &block)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def hospodar_check_inheritance!(component_class, base_class)
|
25
25
|
return if component_class.nil? || base_class.nil?
|
26
26
|
raise(ArgumentError, "must be a subclass of #{base_class.inspect}") unless component_class <= base_class
|
27
27
|
end
|
data/lib/hospodar/version.rb
CHANGED