class Orchestra::RunList::Builder::Sorter
Public Class Methods
new(steps_hash)
click to toggle source
# File lib/orchestra/run_list.rb, line 127 def initialize steps_hash @steps = steps_hash end
Public Instance Methods
build_dependencies_for(step)
click to toggle source
# File lib/orchestra/run_list.rb, line 146 def build_dependencies_for step step.required_dependencies.each_with_object Set.new do |dep, set| provider = provider_for dep set << provider if provider end end
build_dependency_tree()
click to toggle source
# File lib/orchestra/run_list.rb, line 140 def build_dependency_tree @hsh = @steps.each_with_object Hash.new do |(name, step), hsh| hsh[name] = build_dependencies_for step end end
effective_provisions_for(step, dep)
click to toggle source
# File lib/orchestra/run_list.rb, line 170 def effective_provisions_for step, dep step.optional_dependencies | step.provisions end
provider_for(dep)
click to toggle source
# File lib/orchestra/run_list.rb, line 162 def provider_for dep @steps.each do |name, step| provisions = effective_provisions_for step, dep return name if provisions.include? dep end nil end
sort!()
click to toggle source
# File lib/orchestra/run_list.rb, line 131 def sort! build_dependency_tree tsort.each do |name| @steps[name] = @steps.delete name end rescue TSort::Cyclic raise CircularDependencyError.new end
tsort_each_child(name, &block)
click to toggle source
# File lib/orchestra/run_list.rb, line 157 def tsort_each_child(name, &block) deps = @hsh.fetch name deps.each &block end
tsort_each_node(&block)
click to toggle source
# File lib/orchestra/run_list.rb, line 153 def tsort_each_node(&block) @hsh.each_key &block end