rake_factory 0.9.0.pre.1 → 0.10.0.pre.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/rake_factory/configurable.rb +2 -3
- data/lib/rake_factory/parameter_set.rb +1 -1
- data/lib/rake_factory/parameter_view.rb +18 -10
- data/lib/rake_factory/task.rb +2 -1
- data/lib/rake_factory/task_set.rb +21 -8
- data/lib/rake_factory/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: 0bf8018e6e08f7c867a567d9c1e46bda22a792ac76b7a837456fa63ad93e0761
|
4
|
+
data.tar.gz: 40dea28362c1ad5960598337a34a6316ff6f5a0a4783e33da330d101e0fcdbda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f869475844cd030417393da31547810e2d2ca256d3d4226d6cb31e879295a5d59c4d69ad0c5efdf076b1690d254bb46f291dd5fe119843c7ec7e131b7727b602
|
7
|
+
data.tar.gz: fbe41de1ef13ce3d60859d85c01387d39ff59128fad9434644147050a858f5d04ea0c6a9c229d2d66e2aae260fb0b1dfd3f077a11f58502fa0e4ee476cf542ec
|
data/Gemfile.lock
CHANGED
@@ -16,10 +16,9 @@ module RakeFactory
|
|
16
16
|
set_if_value_present(:configuration_block, configuration_block)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def invoke_configuration_block_on(target, args)
|
20
20
|
if configuration_block
|
21
|
-
|
22
|
-
params = args ? [view, args] : [view]
|
21
|
+
params = args ? [target, args] : [target]
|
23
22
|
configuration_block.call(
|
24
23
|
*params.slice(0, configuration_block.arity))
|
25
24
|
end
|
@@ -2,26 +2,34 @@ module RakeFactory
|
|
2
2
|
class ParameterView
|
3
3
|
attr_reader(:task)
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(target, reader_class, writer_class, args)
|
6
6
|
self.instance_eval do
|
7
|
-
|
7
|
+
reader_class.parameter_set.each do |parameter|
|
8
8
|
define_singleton_method parameter.reader_method do
|
9
|
-
|
9
|
+
target.send(parameter.reader_method)
|
10
10
|
end
|
11
|
-
|
11
|
+
end
|
12
|
+
writer_class.parameter_set.each do |parameter|
|
12
13
|
if parameter.configurable?
|
13
14
|
define_singleton_method parameter.writer_method do |value|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
if target.respond_to?(parameter.writer_method)
|
16
|
+
resolved_value = lambda do |t|
|
17
|
+
params = args ? [t, args] : [t]
|
18
|
+
value.respond_to?(:call) ?
|
19
|
+
value.call(*params.slice(0, value.arity)) :
|
20
|
+
value
|
21
|
+
end
|
22
|
+
target.send(parameter.writer_method, resolved_value)
|
19
23
|
end
|
20
|
-
task.send(parameter.writer_method, resolved_value)
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
28
|
+
self.class.instance_eval do
|
29
|
+
define_singleton_method :parameter_set do
|
30
|
+
reader_class.parameter_set
|
31
|
+
end
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
end
|
data/lib/rake_factory/task.rb
CHANGED
@@ -27,7 +27,8 @@ module RakeFactory
|
|
27
27
|
argument_names => prerequisites,
|
28
28
|
order_only: order_only_prerequisites
|
29
29
|
) do |_, args|
|
30
|
-
|
30
|
+
view = ParameterView.new(self, self.class, self.class, args)
|
31
|
+
invoke_configuration_block_on(view, args)
|
31
32
|
check_parameter_requirements
|
32
33
|
invoke_actions(args)
|
33
34
|
end
|
@@ -18,12 +18,11 @@ module RakeFactory
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def task(klass, *args, &block)
|
21
|
-
tasks <<
|
21
|
+
tasks << TaskSpecification.new(klass, args, &block)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def define_on(application)
|
26
|
-
invoke_configuration_block
|
27
26
|
around_define(application) do
|
28
27
|
self.class.tasks.each do |task_definition|
|
29
28
|
task_definition
|
@@ -88,22 +87,30 @@ module RakeFactory
|
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
91
|
-
|
90
|
+
class TaskSpecification
|
91
|
+
attr_reader :klass, :args, :block
|
92
|
+
|
93
|
+
def initialize(klass, args, &block)
|
94
|
+
@klass = klass
|
95
|
+
@args = args
|
96
|
+
@block = block
|
97
|
+
end
|
98
|
+
|
99
|
+
def for_task_set(task_set)
|
100
|
+
TaskDefinition.new(klass, args, task_set, &block)
|
101
|
+
end
|
102
|
+
end
|
92
103
|
|
93
104
|
class TaskDefinition
|
94
105
|
attr_reader :task_set, :klass, :args, :block
|
95
106
|
|
96
|
-
def initialize(klass, args, task_set
|
107
|
+
def initialize(klass, args, task_set, &block)
|
97
108
|
@task_set = task_set
|
98
109
|
@klass = klass
|
99
110
|
@args = args
|
100
111
|
@block = block
|
101
112
|
end
|
102
113
|
|
103
|
-
def for_task_set(task_set)
|
104
|
-
self.class.new(klass, args, task_set, &block)
|
105
|
-
end
|
106
|
-
|
107
114
|
def define_on(application)
|
108
115
|
if should_define?
|
109
116
|
klass.new(*resolve_arguments, &resolve_block).define_on(application)
|
@@ -131,10 +138,16 @@ module RakeFactory
|
|
131
138
|
if block.respond_to?(:call)
|
132
139
|
block.call(*[task_set, t, args].slice(0, block.arity))
|
133
140
|
end
|
141
|
+
if task_set.configuration_block.respond_to?(:call)
|
142
|
+
view = ParameterView.new(t, t.class, task_set.class, args)
|
143
|
+
task_set.invoke_configuration_block_on(view, args)
|
144
|
+
end
|
134
145
|
end
|
135
146
|
end
|
136
147
|
end
|
137
148
|
|
149
|
+
private_constant :TaskArguments
|
150
|
+
private_constant :TaskSpecification
|
138
151
|
private_constant :TaskDefinition
|
139
152
|
end
|
140
153
|
end
|
data/lib/rake_factory/version.rb
CHANGED