Class JavaClass::Dependencies::Graph
In: lib/javaclass/dependencies/graph.rb
Parent: Object

A graph contains a list of Node

Author:Peter Kofler

Methods

Public Class methods

[Source]

# File lib/javaclass/dependencies/graph.rb, line 13
      def initialize
        @nodes = []
      end

Public Instance methods

Add a node to this graph.

[Source]

# File lib/javaclass/dependencies/graph.rb, line 18
      def add(node)
        @nodes << node
      end

Iterate all nodes in this Graph and call block for each Node

[Source]

# File lib/javaclass/dependencies/graph.rb, line 46
      def each_node(&block)
        @nodes.each { |node| block.call(node) }
      end

Find the nodes that satisfy the given dependency

[Source]

# File lib/javaclass/dependencies/graph.rb, line 41
      def nodes_satisfying(dependency)
        @nodes.find_all { |n| n.satisfies?(dependency) }
      end

Iterates all nodes and fills the dependency fields of the Node.

[Source]

# File lib/javaclass/dependencies/graph.rb, line 27
      def resolve_dependencies
        @nodes.each do |node|
          puts "processing #{node}"

          node.outgoing_dependencies do |dependency|
            providers = nodes_satisfying(dependency.target)
            node.add_dependency(dependency, providers)
          end
          
          node.dependencies.values.each { |vals| vals.sort! }
        end
      end

[Source]

# File lib/javaclass/dependencies/graph.rb, line 22
      def to_a
        @nodes.dup
      end

[Validate]