Class: Datadog::CI::CodeCoverage::Component
- Inherits:
-
Object
- Object
- Datadog::CI::CodeCoverage::Component
- Defined in:
- lib/datadog/ci/code_coverage/component.rb
Overview
CodeCoverage component is responsible for uploading code coverage reports to Datadog’s Code Coverage product.
Constant Summary collapse
- COVERAGE_REPORT_TYPE =
"coverage_report"
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
Instance Method Summary collapse
- #configure(library_configuration) ⇒ Object
-
#initialize(enabled:, transport:) ⇒ Component
constructor
A new instance of Component.
- #shutdown! ⇒ Object
- #upload(serialized_report:, format:) ⇒ Object
Constructor Details
#initialize(enabled:, transport:) ⇒ Component
Returns a new instance of Component.
16 17 18 19 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 16 def initialize(enabled:, transport:) @enabled = enabled @transport = transport end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
14 15 16 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 14 def enabled @enabled end |
Instance Method Details
#configure(library_configuration) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 21 def configure(library_configuration) @enabled &&= library_configuration.coverage_report_upload_enabled? Datadog.logger.debug do "[#{self.class.name}] Configured with enabled=#{@enabled}" end end |
#shutdown! ⇒ Object
40 41 42 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 40 def shutdown! # noop - transport is synchronous end |
#upload(serialized_report:, format:) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 29 def upload(serialized_report:, format:) return unless @enabled return if serialized_report.nil? Datadog.logger.debug { "[#{self.class.name}] Uploading coverage report..." } event = build_event(format) @transport.send_coverage_report(event: event, coverage_report: serialized_report) end |