Class: GitlabQuality::TestTooling::CodeCoverage::LcovFile

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_quality/test_tooling/code_coverage/lcov_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(lcov_file_content) ⇒ LcovFile

Returns a new instance of LcovFile.

Parameters:

  • lcov_file_content (String)

    The content of the lcov file



8
9
10
# File 'lib/gitlab_quality/test_tooling/code_coverage/lcov_file.rb', line 8

def initialize(lcov_file_content)
  @lcov_file_content = lcov_file_content
end

Instance Method Details

#parsed_contentHash<String, Hash>

}

Examples:

Return value

{
  "path/to/file1.rb" => {
    line_coverage: { 1 => 1, 2 => 0 },
    branch_coverage: {},
    total_lines: 2,
    covered_lines: 1,
    percentage: 50.0,
    total_branches: 4,
    covered_branches: 3,
    branch_percentage: 75.0,
    total_functions: 2,
    covered_functions: 1,
    function_percentage: 50.0
  },
  ...

Returns:

  • (Hash<String, Hash>)

    The parsed content of the lcov file



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gitlab_quality/test_tooling/code_coverage/lcov_file.rb', line 30

def parsed_content
  return @parsed_content if @parsed_content

  @parsed_content = {}
  @current_file = nil

  @lcov_file_content.each_line { |line| parse_line(line) }

  include_coverage
  @parsed_content
end