Class: Project

Inherits:
Object
  • Object
show all
Includes:
DirectoryParser
Defined in:
lib/cpp_dependency_graph/project.rb

Overview

Parses all components of a project

Instance Method Summary collapse

Methods included from DirectoryParser

#fetch_all_dirs, #glob_files

Constructor Details

#initialize(path) ⇒ Project

Returns a new instance of Project.



13
14
15
16
# File 'lib/cpp_dependency_graph/project.rb', line 13

def initialize(path)
  @path = path
  @include_resolver = IncludeToComponentResolver.new(source_components)
end

Instance Method Details

#dependencies(component) ⇒ Object



36
37
38
39
# File 'lib/cpp_dependency_graph/project.rb', line 36

def dependencies(component)
  # TODO: This is repeating the same work twice! component_for_include is called when calling external_includes
  external_includes(component).map { |include| @include_resolver.component_for_include(include) }.reject(&:empty?).uniq
end

#external_includes(component) ⇒ Object



41
42
43
# File 'lib/cpp_dependency_graph/project.rb', line 41

def external_includes(component)
  @include_resolver.external_includes(component)
end

#project_componentObject



28
29
30
# File 'lib/cpp_dependency_graph/project.rb', line 28

def project_component
  @project_component ||= build_project_component
end

#source_component(name) ⇒ Object



22
23
24
25
26
# File 'lib/cpp_dependency_graph/project.rb', line 22

def source_component(name)
  return SourceComponent.new('NULL') unless source_components.key?(name)

  source_components[name]
end

#source_componentsObject



18
19
20
# File 'lib/cpp_dependency_graph/project.rb', line 18

def source_components
  @source_components ||= build_source_components
end

#source_filesObject



32
33
34
# File 'lib/cpp_dependency_graph/project.rb', line 32

def source_files
  @source_files ||= build_source_files
end