Class: Gitlab::Ci::Reports::CoverageReports

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/coverage_reports.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCoverageReports

Returns a new instance of CoverageReports.


9
10
11
# File 'lib/gitlab/ci/reports/coverage_reports.rb', line 9

def initialize
  @files = {}
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.


7
8
9
# File 'lib/gitlab/ci/reports/coverage_reports.rb', line 7

def files
  @files
end

Instance Method Details

#add_file(name, line_coverage) ⇒ Object


21
22
23
24
25
26
27
28
# File 'lib/gitlab/ci/reports/coverage_reports.rb', line 21

def add_file(name, line_coverage)
  if files[name].present?
    line_coverage.each { |line, hits| combine_lines(name, line, hits) }

  else
    files[name] = line_coverage
  end
end

#pick(keys) ⇒ Object


13
14
15
16
17
18
19
# File 'lib/gitlab/ci/reports/coverage_reports.rb', line 13

def pick(keys)
  coverage_files = files.select do |key|
    keys.include?(key)
  end

  { files: coverage_files }
end