jpmckinney/pupa-ruby

View on GitHub
lib/pupa/processor/dependency_graph.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'tsort'

module Pupa
  class Processor
    # A simple implementation of a dependency graph.
    #
    # @see http://ruby-doc.org/stdlib-2.0.0/libdoc/tsort/rdoc/TSort.html
    class DependencyGraph < Hash
      include TSort

      alias tsort_each_node each_key

      def tsort_each_child(node, &block)
        fetch(node).each(&block)
      end
    end
  end
end