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

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/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
# File 'lib/gitlab/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]
  }

  @pipeline = @project.ci_pipelines.latest_successful_for_ref(@ref)
end

Instance Attribute Details

#customizationObject (readonly)

Returns the value of attribute customization


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

def customization
  @customization
end

#jobObject (readonly)

Returns the value of attribute job


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

def job
  @job
end

#projectObject (readonly)

Returns the value of attribute project


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

def project
  @project
end

#refObject (readonly)

Returns the value of attribute ref


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

def ref
  @ref
end

Instance Method Details

#entityObject


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

def entity
  'coverage'
end

#metadataObject


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

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

#statusObject


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

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

  @coverage.to_f.round(2)
end

#templateObject


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

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