Class: Dopi::CommandSet
- Inherits:
-
Object
show all
- Includes:
- State
- Defined in:
- lib/dopi/command_set.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from State
#delete_on_signal, #on_signal, #reset_signals, #send_signal, #signal_procs, #signals, #state, #state_add_child, #state_auto_evaluate_children, #state_auto_evaluate_children=, #state_changed, #state_children, #state_children_done?, #state_children_failed?, #state_children_partial?, #state_children_ready?, #state_children_running?, #state_children_running_noop?, #state_children_starting?, #state_done?, #state_fail, #state_failed?, #state_finish, #state_partial?, #state_ready, #state_ready?, #state_reset, #state_reset_with_children, #state_run, #state_run_noop, #state_running?, #state_running_noop?, #state_start, #state_starting?, #to_yaml_properties, #update, #update_mutex
Constructor Details
#initialize(step_parser, step, node) ⇒ CommandSet
Returns a new instance of CommandSet.
14
15
16
17
18
19
20
21
|
# File 'lib/dopi/command_set.rb', line 14
def initialize(step_parser, step, node)
@step_parser = step_parser
@step = step
@plan = step.plan
@node = node
commands.each{|command| state_add_child(command)}
end
|
Instance Attribute Details
#node ⇒ Object
Returns the value of attribute node.
12
13
14
|
# File 'lib/dopi/command_set.rb', line 12
def node
@node
end
|
#plan ⇒ Object
Returns the value of attribute plan.
12
13
14
|
# File 'lib/dopi/command_set.rb', line 12
def plan
@plan
end
|
#step ⇒ Object
Returns the value of attribute step.
12
13
14
|
# File 'lib/dopi/command_set.rb', line 12
def step
@step
end
|
Instance Method Details
#commands ⇒ Object
27
28
29
30
31
|
# File 'lib/dopi/command_set.rb', line 27
def commands
@commands ||= @step_parser.commands.map do |command|
Dopi::Command.create_plugin_instance(command, @step, node)
end
end
|
#load_state(state_hash) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/dopi/command_set.rb', line 50
def load_state(state_hash)
return if state_hash.empty?
commands.each_with_index do |command, i|
command.load_state(state_hash[i])
end
end
|
#name ⇒ Object
23
24
25
|
# File 'lib/dopi/command_set.rb', line 23
def name
@node.name
end
|
#run(noop) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/dopi/command_set.rb', line 42
def run(noop)
commands.each do |command|
break if state_failed? or signals[:stop]
command.meta_run(noop)
break unless command.state_done?
end
end
|
#state_hash ⇒ Object
57
58
59
60
61
|
# File 'lib/dopi/command_set.rb', line 57
def state_hash
commands.map do |command|
command.state_hash
end
end
|
#valid? ⇒ Boolean
33
34
35
36
37
38
39
40
|
# File 'lib/dopi/command_set.rb', line 33
def valid?
begin
commands.all?{|command| command.meta_valid?}
rescue PluginLoaderError => e
Dopi.log.error("Step '#{name}': Can't load plugin : #{e.message}")
false
end
end
|