class FileDependencyGraph
Dependency tree/graph of entire project
Public Class Methods
new(project)
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 9 def initialize(project) @project = project end
Public Instance Methods
all_cyclic_links()
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 17 def all_cyclic_links @all_cyclic_links ||= build_cyclic_links end
all_links()
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 13 def all_links @all_links ||= build_hash_links end
links(name)
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 21 def links(name) return {} unless all_links.key?(name) links = incoming_links(name) links.merge!(outgoing_links(name)) links end
Private Instance Methods
build_cyclic_links()
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 41 def build_cyclic_links cyclic_links = all_links.select { |_, links| links.any?(&:cyclic?) } cyclic_links.each_value { |links| links.select!(&:cyclic?) } end
build_hash_links()
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 31 def build_hash_links raw_links = @project.source_components.values.map { |c| [c.name, @project.dependencies(c)] }.to_h @cycle_detector ||= CycleDetector.new(raw_links) links = raw_links.map do |source, source_links| c_links = source_links.map { |target| Link.new(source, target, @cycle_detector.cyclic?(source, target)) } [source, c_links] end.to_h links end
incoming_links(target)
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 50 def incoming_links(target) incoming_c_links = all_links.select { |_, c_links| c_links.any? { |link| link.target == target } } incoming_c_links.map do |source, _| link = Link.new(source, target, @cycle_detector.cyclic?(source, target)) [source, [link]] end.to_h end
outgoing_links(name)
click to toggle source
# File lib/cpp_dependency_graph/file_dependency_graph.rb, line 46 def outgoing_links(name) all_links.slice(name) end