Class: Build::Graph::Task
- Inherits:
-
Object
- Object
- Build::Graph::Task
- Defined in:
- lib/build/graph/walker.rb
Overview
A task is a specific process and scope applied to a graph node.
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #exit ⇒ Object
-
#initialize(controller, walker, node) ⇒ Task
constructor
A new instance of Task.
- #inputs ⇒ Object
- #outputs ⇒ Object
-
#visit ⇒ Object
Derived task should override this function to provide appropriate behaviour.
- #wet? ⇒ Boolean
Constructor Details
#initialize(controller, walker, node) ⇒ Task
Returns a new instance of Task.
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/build/graph/walker.rb', line 129 def initialize(controller, walker, node) @controller = controller @node = node @walker = walker # If the execution of the node fails, this is where we save the error: @error = nil @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
140 141 142 |
# File 'lib/build/graph/walker.rb', line 140 def children @children end |
Instance Method Details
#exit ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/build/graph/walker.rb', line 171 def exit if @error || any_child_failed? || any_inputs_failed? @node.fail! elsif wet? @node.clean! end @walker.exit(@node) @walker.count += 1 end |
#inputs ⇒ Object
142 143 144 |
# File 'lib/build/graph/walker.rb', line 142 def inputs @node.inputs end |
#outputs ⇒ Object
146 147 148 |
# File 'lib/build/graph/walker.rb', line 146 def outputs @node.outputs end |
#visit ⇒ Object
Derived task should override this function to provide appropriate behaviour.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/build/graph/walker.rb', line 155 def visit wait_for_inputs # If all inputs were good, we can update the node. unless any_inputs_failed? begin yield rescue TransientError => error $stderr.puts Rainbow("Error: #{error.inspect}").red @error = error end end wait_for_children end |
#wet? ⇒ Boolean
150 151 152 |
# File 'lib/build/graph/walker.rb', line 150 def wet? @node.dirty? end |