Sha256: d700218a4785c81338457be30efe77f6c6bc2d7fee6e2a79878885f8a6a0c9d1
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# Created by Luke Kanies on 2006-11-16. # Copyright (c) 2006. All rights reserved. require 'puppet' require 'puppet/pgraph' # 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::PGraph.new self.each do |child| unless block_given? and ! yield(child) graph.add_edge!(self, child) if graph.cyclic? raise Puppet::Error, "%s created a cyclic graph" % self end if child.respond_to?(:to_graph) child.to_graph(graph, &block) end end end if graph.cyclic? raise Puppet::Error, "%s created a cyclic graph" % self end graph end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puppet-0.24.0 | lib/puppet/util/graph.rb |
puppet-0.24.1 | lib/puppet/util/graph.rb |