Class: Gitlab::Ci::Badge::Coverage::Report

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/ci/badge/coverage/report.rb

Overview

Test coverage report badge

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, ref, opts: { job: nil }) ⇒ Report

Returns a new instance of Report.


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 12

def initialize(project, ref, opts: { job: nil })
  @project = project
  @ref = ref
  @job = opts[:job]
  @customization = {
    key_width: opts[:key_width].to_i,
    key_text: opts[:key_text],
    min_good: opts[:min_good].to_i,
    min_acceptable: opts[:min_acceptable].to_i,
    min_medium: opts[:min_medium].to_i
  }
end

Instance Attribute Details

#customizationObject (readonly)

Returns the value of attribute customization.


10
11
12
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 10

def customization
  @customization
end

#jobObject (readonly)

Returns the value of attribute job.


10
11
12
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 10

def job
  @job
end

#projectObject (readonly)

Returns the value of attribute project.


10
11
12
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 10

def project
  @project
end

#refObject (readonly)

Returns the value of attribute ref.


10
11
12
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 10

def ref
  @ref
end

Instance Method Details

#entityObject


25
26
27
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 25

def entity
  'coverage'
end

#metadataObject


36
37
38
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 36

def 
  @metadata ||= Coverage::Metadata.new(self)
end

#statusObject


29
30
31
32
33
34
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 29

def status
  @coverage ||= raw_coverage
  return unless @coverage

  @coverage.round(2)
end

#templateObject


40
41
42
# File 'lib/gitlab/ci/badge/coverage/report.rb', line 40

def template
  @template ||= Coverage::Template.new(self)
end