4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/rundock/builder/operation_builder.rb', line 4
def build_first(scenario, targets, tasks, hooks)
parsing_node_attribute = nil
scen = Scenario.new
scen.tasks = tasks
scenario.each do |sn|
nodes = []
operations = []
hook_contents = []
sn.deep_symbolize_keys.each do |sk, sv|
if sk == :target
target_builder = TargetBuilder.new(@options)
target = target_builder.build(sv, targets)
if target.is_a?(Node)
nodes = Array(target)
parsing_node_attribute = build_node_attribute(scen, sv, parsing_node_attribute, tasks, target_builder.parsed_node_options[sv.to_sym])
operations = Array(build_cli_command_operation(@options[:command], parsing_node_attribute, @options)) if @options[:command]
end
elsif sk == :target_group
target_builder = TargetBuilder.new(@options)
nodes = target_builder.build_group(sv, targets)
nodes.each do |n|
if n.is_a?(Node)
parsing_node_attribute = build_node_attribute(scen, n.name, parsing_node_attribute, tasks, target_builder.parsed_node_options[n.name.to_sym])
operations = Array(build_cli_command_operation(@options[:command], parsing_node_attribute, @options)) if @options[:command]
end
end
elsif sk == :hook
hooks_builder = HookBuilder.new(@options)
hook_contents = hooks_builder.build(Array(sv), hooks)
parsing_node_attribute.hooks = hooks_builder.enable_hooks
else
ope = build_operations(sk, Array(sv), parsing_node_attribute, @options, false)
operations << ope if ope
end
end
nodes.each do |n|
operations.each do |o|
n.add_operation(o)
end
n.hooks = hook_contents
end
scen.nodes.concat(nodes)
end
scen
end
|