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

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/util/graph.rb
puppet-parse-0.1.3 lib/vendor/puppet/util/graph.rb
puppet-parse-0.1.2 lib/vendor/puppet/util/graph.rb
puppet-parse-0.1.1 lib/vendor/puppet/util/graph.rb
puppet-2.7.26 lib/puppet/util/graph.rb
puppet-2.7.25 lib/puppet/util/graph.rb
puppet-2.7.24 lib/puppet/util/graph.rb
puppet-3.2.4 lib/puppet/util/graph.rb
puppet-2.7.23 lib/puppet/util/graph.rb
puppet-3.2.3 lib/puppet/util/graph.rb
puppet-3.2.3.rc1 lib/puppet/util/graph.rb
puppet-3.2.2 lib/puppet/util/graph.rb
puppet-2.7.22 lib/puppet/util/graph.rb
puppet-3.2.1 lib/puppet/util/graph.rb
puppet-3.2.1.rc1 lib/puppet/util/graph.rb
puppet-3.2.0.rc2 lib/puppet/util/graph.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/lib/puppet/util/graph.rb
puppet-3.2.0.rc1 lib/puppet/util/graph.rb
puppet-parse-0.1.0 lib/vendor/puppet/util/graph.rb
puppet-parse-0.0.6 lib/vendor/puppet/util/graph.rb