Class: SourceComponent

Inherits:
Object
  • Object
show all
Includes:
Config
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 Config

#source_file_extensions

Constructor Details

#initialize(path) ⇒ SourceComponent

Returns a new instance of SourceComponent.



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

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



10
11
12
# File 'lib/cpp_dependency_graph/source_component.rb', line 10

def path
  @path
end

Instance Method Details

#includesObject



24
25
26
# File 'lib/cpp_dependency_graph/source_component.rb', line 24

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

#locObject



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

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

#nameObject



16
17
18
# File 'lib/cpp_dependency_graph/source_component.rb', line 16

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

#source_filesObject



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

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