Class: SourceComponent

Inherits:
Object
  • Object
show all
Includes:
Config, DirectoryParser
Defined in:
lib/cpp_dependency_graph/source_component.rb

Overview

Abstracts a source directory containing source files

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DirectoryParser

#fetch_all_dirs, #glob_files

Methods included from Config

#source_file_extensions

Constructor Details

#initialize(path) ⇒ SourceComponent

Returns a new instance of SourceComponent.



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

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



12
13
14
# File 'lib/cpp_dependency_graph/source_component.rb', line 12

def path
  @path
end

Instance Method Details

#includesObject



26
27
28
# File 'lib/cpp_dependency_graph/source_component.rb', line 26

def includes
  @includes ||= source_files.flat_map(&:includes).uniq.map { |include| File.basename(include) }
end

#locObject



30
31
32
# File 'lib/cpp_dependency_graph/source_component.rb', line 30

def loc
  @loc ||= source_files.inject(0) { |total_loc, file| total_loc + file.loc }
end

#nameObject



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

def name
  @name ||= File.basename(@path)
end

#source_filesObject



22
23
24
# File 'lib/cpp_dependency_graph/source_component.rb', line 22

def source_files
  @source_files ||= parse_source_files(source_file_extensions)
end