Class: SimpleCov::Result::SourceFileBuilder
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/simplecov/result/source_file_builder.rb |
Overview
Constructs ::SimpleCov::SourceFile instances from a raw coverage
hash, sorts them by filename, and surfaces filenames whose source
is no longer present on disk so the caller can warn about the
silent drop (see #980).
Class Method Summary
Instance Attribute Summary
- #missing_source_files readonly
Instance Method Summary
- #call
- #build_source_file(filename, coverage) private
-
#stringify_outer_keys(coverage)
private
Coverage.resultreturns symbol keys (:lines,:branches,:methods); resultsets loaded from disk are already string-keyed.
Constructor Details
.new(original_result, not_loaded_files:) ⇒ SourceFileBuilder
# File 'lib/simplecov/result/source_file_builder.rb', line 12
def initialize(original_result, not_loaded_files:) @original_result = original_result @not_loaded_files = not_loaded_files @missing_source_files = [] end
Instance Attribute Details
#missing_source_files (readonly)
[ GitHub ]# File 'lib/simplecov/result/source_file_builder.rb', line 10
attr_reader :missing_source_files
Instance Method Details
#build_source_file(filename, coverage) (private)
[ GitHub ]# File 'lib/simplecov/result/source_file_builder.rb', line 28
def build_source_file(filename, coverage) unless File.file?(filename) @missing_source_files << filename return end SimpleCov::SourceFile.new( filename, stringify_outer_keys(coverage), loaded: !@not_loaded_files.include?(filename) ) end
#call
[ GitHub ]#stringify_outer_keys(coverage) (private)
Coverage.result returns symbol keys (:lines, :branches,
:methods); resultsets loaded from disk are already string-keyed.
::SimpleCov::SourceFile reads with strings, and handles both Array and
stringified-Array branch/method keys via restore_ruby_data_structure,
so only the outer hash needs normalizing.