Class: IncludeDependencyGraph
- Inherits:
-
Object
- Object
- IncludeDependencyGraph
- Defined in:
- lib/cpp_dependency_graph/include_dependency_graph.rb
Overview
Returns a hash of intra-component include links
Instance Method Summary collapse
- #all_cyclic_links ⇒ Object
- #all_links ⇒ Object
-
#initialize(project) ⇒ IncludeDependencyGraph
constructor
A new instance of IncludeDependencyGraph.
- #links(component_name) ⇒ Object
Constructor Details
#initialize(project) ⇒ IncludeDependencyGraph
Returns a new instance of IncludeDependencyGraph.
9 10 11 |
# File 'lib/cpp_dependency_graph/include_dependency_graph.rb', line 9 def initialize(project) @project = project end |
Instance Method Details
#all_cyclic_links ⇒ Object
23 24 25 |
# File 'lib/cpp_dependency_graph/include_dependency_graph.rb', line 23 def all_cyclic_links # TODO: Implement end |
#all_links ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/cpp_dependency_graph/include_dependency_graph.rb', line 13 def all_links components = @project.source_components all_source_files = components.values.flat_map(&:source_files) all_source_files.map do |file| source = file.basename links = file.includes.map { |inc| Link.new(source, inc, false) } [source, links] end.to_h end |
#links(component_name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cpp_dependency_graph/include_dependency_graph.rb', line 27 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 source = file.basename internal_includes = file.includes.reject { |inc| external_includes.any?(inc) } links = internal_includes.map { |inc| Link.new(source, inc, false) } [source, links] end.to_h end |