Sha256: 4021aad6917bc7669a51e5753f2aa770c4737226a0c10a06f4e0311e35cfd952
Contents?: true
Size: 791 Bytes
Versions: 67
Compression:
Stored size: 791 Bytes
Contents
require 'puppet' require 'puppet/simple_graph' # A module that handles the small amount of graph stuff in Puppet. module Puppet::Util::Graph # Make a graph where each of our children gets converted to # the receiving end of an edge. Call the same thing on all # of our children, optionally using a block def to_graph(graph = nil, &block) # Allow our calling function to send in a graph, so that we # can call this recursively with one graph. graph ||= Puppet::SimpleGraph.new self.each do |child| unless block_given? and ! yield(child) graph.add_edge(self, child) child.to_graph(graph, &block) if child.respond_to?(:to_graph) end end # Do a topsort, which will throw an exception if the graph is cyclic. graph end end
Version data entries
67 entries across 67 versions & 4 rubygems