Class: SourceComponent
- Inherits:
-
Object
- Object
- SourceComponent
- Includes:
- Config
- Defined in:
- lib/cpp_dependency_graph/source_component.rb
Overview
Abstracts a source directory containing source files
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #includes ⇒ Object
-
#initialize(path) ⇒ SourceComponent
constructor
A new instance of SourceComponent.
- #loc ⇒ Object
- #name ⇒ Object
- #source_files ⇒ Object
Methods included from Config
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
#path ⇒ Object (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
#includes ⇒ Object
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 |
#loc ⇒ Object
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 |
#name ⇒ Object
16 17 18 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 16 def name @name ||= File.basename(@path) end |
#source_files ⇒ Object
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 |