Class: Build::Graph::Controller
- Inherits:
-
Files::Monitor
- Object
- Files::Monitor
- Build::Graph::Controller
- Defined in:
- lib/build/graph/controller.rb
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #build_graph! ⇒ Object
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
-
#traverse!(walker) ⇒ Object
You need to override this to traverse the top nodes as required:.
- #update! ⇒ Object
- #update_with_log ⇒ Object
- #walk(&block) ⇒ Object
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
31 32 33 34 35 36 37 |
# File 'lib/build/graph/controller.rb', line 31 def initialize super @nodes = {} build_graph! end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
39 40 41 |
# File 'lib/build/graph/controller.rb', line 39 def nodes @nodes end |
Instance Method Details
#build_graph! ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/build/graph/controller.rb', line 52 def build_graph! # We build the graph without doing any actual execution: nodes = [] walker = walk do |walker, node| nodes << node yield walker, node end traverse! walker # We should update the status of all nodes in the graph once we've traversed the graph. nodes.each do |node| node.update_status! end end |
#traverse!(walker) ⇒ Object
You need to override this to traverse the top nodes as required:
42 43 44 45 46 |
# File 'lib/build/graph/controller.rb', line 42 def traverse!(walker) #Array(top).each do |node| # node.update!(walker) #end end |
#update! ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/build/graph/controller.rb', line 84 def update! walker = walk do |walker, node| yield walker, node end traverse! walker return walker end |
#update_with_log ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/build/graph/controller.rb', line 70 def update_with_log puts Rainbow("*** Graph update traversal ***").green start_time = Time.now walker = update! ensure end_time = Time.now elapsed_time = end_time - start_time $stdout.flush $stderr.puts Rainbow("Graph Update Time: %0.3fs" % elapsed_time).magenta end |
#walk(&block) ⇒ Object
48 49 50 |
# File 'lib/build/graph/controller.rb', line 48 def walk(&block) Walker.new(self, &block) end |