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"- MAX_REPORT_FLAGS =
32
Instance Attribute Summary collapse
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
Instance Method Summary collapse
- #configure(library_configuration) ⇒ Object
-
#initialize(enabled:, transport:, flags:) ⇒ Component
constructor
A new instance of Component.
- #shutdown! ⇒ Object
- #upload(serialized_report:, format:) ⇒ Object
Constructor Details
#initialize(enabled:, transport:, flags:) ⇒ Component
Returns a new instance of Component.
18 19 20 21 22 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 18 def initialize(enabled:, transport:, flags:) @enabled = enabled @transport = transport @flags = parse_flags(flags) end |
Instance Attribute Details
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
16 17 18 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 16 def enabled @enabled end |
Instance Method Details
#configure(library_configuration) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 24 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
43 44 45 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 43 def shutdown! # noop - transport is synchronous end |
#upload(serialized_report:, format:) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/datadog/ci/code_coverage/component.rb', line 32 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 |