class Dk::TreeRunner
Constants
- LEVEL_BULLET
- LEVEL_PREFIX
Public Class Methods
new(config, kernel)
click to toggle source
Calls superclass method
Dk::DryRunner::new
# File lib/dk/tree_runner.rb, line 14 def initialize(config, kernel) super(config, :logger => NullLogger.new) # disable any logging @task_run_stack = [self] @run_num = 0 @kernel = kernel end
Public Instance Methods
run(*args)
click to toggle source
Calls superclass method
# File lib/dk/tree_runner.rb, line 22 def run(*args) # wipe the task runs before every run; that way `output_task_runs` outputs # just this run's task runs self.runs.clear # increment the run num and run the task @run_num += 1 task = super # recursively output the task runs in a tree format output_task_runs(self.runs, 0, "#{@run_num}) ".rjust(LEVEL_PREFIX.size, ' ')) # return the top-level task that was run task end
Private Instance Methods
build_and_run_task(task_class, params = nil)
click to toggle source
track all task runs
Calls superclass method
# File lib/dk/tree_runner.rb, line 41 def build_and_run_task(task_class, params = nil) task_run = TaskRun.new(task_class, params) @task_run_stack.last.runs << task_run @task_run_stack.push(task_run) task = super(task_class, params) @task_run_stack.pop task end
output_task_runs(runs, level, prefix = nil)
click to toggle source
# File lib/dk/tree_runner.rb, line 51 def output_task_runs(runs, level, prefix = nil) runs.each do |task_run| # recursively output the prefix and task class on indented, bulleted lines @kernel.puts "#{LEVEL_PREFIX*level}" \ "#{LEVEL_BULLET if level > 0}" \ "#{prefix}#{task_run.task_class}" output_task_runs(task_run.runs, level+1) end end