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.
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/build/graph/walker.rb', line 126 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.
137 138 139 |
# File 'lib/build/graph/walker.rb', line 137 def children @children end |
Instance Method Details
#exit ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/build/graph/walker.rb', line 169 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
139 140 141 |
# File 'lib/build/graph/walker.rb', line 139 def inputs @node.inputs end |
#outputs ⇒ Object
143 144 145 |
# File 'lib/build/graph/walker.rb', line 143 def outputs @node.outputs end |
#visit ⇒ Object
Derived task should override this function to provide appropriate behaviour.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/build/graph/walker.rb', line 152 def visit wait_for_inputs # If all inputs were good, we can update the node. unless any_inputs_failed? begin #self.instance_eval(&update)e yield rescue TransientError => error $stderr.puts Rainbow("Error: #{error.inspect}").red @error = error end end wait_for_children end |
#wet? ⇒ Boolean
147 148 149 |
# File 'lib/build/graph/walker.rb', line 147 def wet? @node.dirty? end |