Class: IncludeComponentDependencyGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/cpp_dependency_graph/include_component_dependency_graph.rb

Overview

Returns a hash of intra-component include links

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ IncludeComponentDependencyGraph

Returns a new instance of IncludeComponentDependencyGraph.



9
10
11
# File 'lib/cpp_dependency_graph/include_component_dependency_graph.rb', line 9

def initialize(project)
  @project = project
end

Instance Method Details



20
21
22
# File 'lib/cpp_dependency_graph/include_component_dependency_graph.rb', line 20

def all_cyclic_links
  # TODO: Implement
end


13
14
15
16
17
18
# File 'lib/cpp_dependency_graph/include_component_dependency_graph.rb', line 13

def all_links
  @project.source_files.map do |file|
    links = file.includes.map { |inc| Link.new(file.basename, inc, false) }
    [file.basename, links]
  end.to_h
end


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cpp_dependency_graph/include_component_dependency_graph.rb', line 24

def links(component_name)
  component = @project.source_component(component_name)
  source_files = component.source_files
  external_includes = @project.external_includes(component)
  source_files.map do |file|
    # TODO: Very inefficient
    internal_includes = file.includes.reject { |inc| external_includes.any?(inc) }
    links = internal_includes.map { |inc| Link.new(file.basename, inc, false) }
    [file.basename, links]
  end.to_h
end