Class: SourceComponent

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SourceComponent

Returns a new instance of SourceComponent.



6
7
8
# File 'lib/cpp_dependency_graph/source_component.rb', line 6

def initialize(path)
  @path = path
end

Instance Method Details

#includesObject



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

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

#locObject



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

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

#nameObject



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

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

#pathObject



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

def path
  @path
end

#source_filesObject



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

def source_files
  @source_files ||= parse_source_files('.{h,hpp,hxx,c,cpp,cxx,cc}')
end