Class: Autoproj::Ops::PackageSetHierarchy
- Inherits:
-
Object
- Object
- Autoproj::Ops::PackageSetHierarchy
- Defined in:
- lib/autoproj/ops/configuration.rb
Overview
PackageSetHierachy be used to build the hierarchy of package set imports, as directed acyclic graph (DAG) so that they can be (topologically) sorted according to their dependencies
Instance Attribute Summary collapse
-
#dag ⇒ Object
readonly
Returns the value of attribute dag.
Instance Method Summary collapse
-
#flatten ⇒ Object
Flatten the hierarchy, a establish a sorting.
-
#initialize(package_sets, root_pkg_set) ⇒ PackageSetHierarchy
constructor
A new instance of PackageSetHierarchy.
-
#to_png(path) ⇒ Object
Write the hierarchy to an image (png) file.
Constructor Details
#initialize(package_sets, root_pkg_set) ⇒ PackageSetHierarchy
Returns a new instance of PackageSetHierarchy.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/autoproj/ops/configuration.rb', line 18 def initialize(package_sets, root_pkg_set) @dag = RGL::DirectedAdjacencyGraph.new package_sets.each do |p| p.imports.each do |dep| @dag.add_edge dep, p end end @dag.add_vertex root_pkg_set import_order = root_pkg_set.imports.to_a import_order.each_with_index do |p, index| if index + 1 < import_order.size @dag.add_edge p, import_order[index + 1] @dag.add_edge p, root_pkg_set end end unless @dag.acyclic? raise "The package set hierarchy contains cycles: #{@dag.cycles}" end end |
Instance Attribute Details
#dag ⇒ Object (readonly)
Returns the value of attribute dag.
16 17 18 |
# File 'lib/autoproj/ops/configuration.rb', line 16 def dag @dag end |
Instance Method Details
#flatten ⇒ Object
Flatten the hierarchy, a establish a sorting
42 43 44 |
# File 'lib/autoproj/ops/configuration.rb', line 42 def flatten @dag.topsort_iterator.to_a end |
#to_png(path) ⇒ Object
Write the hierarchy to an image (png) file
47 48 49 |
# File 'lib/autoproj/ops/configuration.rb', line 47 def to_png(path) @dag.write_to_graphic_file("png", path.gsub(".png", "")) end |