Class: RSpecTracer::Reporters::PayloadBuilder Private
- Inherits:
-
Object
- Object
- RSpecTracer::Reporters::PayloadBuilder
- Defined in:
- lib/rspec_tracer/reporters/payload_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Builds the canonical reporter payload (schema v1) from a finalized ‘Storage::Snapshot` plus a `run_metadata` Hash. Shared by `JsonReporter` (which `JSON.pretty_generate`s the output) and `HtmlReporter` (which embeds it in a `<script id=“report-data”>` tag). One source of truth for the 5-report shape so JSON and HTML never drift.
‘generated_at` is accepted as a kwarg so callers (especially the golden-file spec for HtmlReporter) can stub it for deterministic output; defaults to `Time.now.utc` to preserve JsonReporter’s 1.x-era emit-time semantics.
Schema changes are additive by default: new keys on an existing object are non-breaking and do NOT bump ‘SCHEMA_VERSION`. Removed or renamed keys bump `SCHEMA_VERSION` and require a downstream coordination pass.
Constant Summary collapse
- SCHEMA_VERSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Internal constant.
1
Class Method Summary collapse
-
.build(snapshot:, run_metadata:, generated_at: nil) ⇒ Object
private
Internal helper for the tracer pipeline.
Instance Method Summary collapse
-
#build ⇒ Object
private
Internal method on the tracer pipeline.
-
#initialize(snapshot:, run_metadata:, generated_at: nil) ⇒ PayloadBuilder
constructor
private
Internal method on the tracer pipeline.
Constructor Details
#initialize(snapshot:, run_metadata:, generated_at: nil) ⇒ PayloadBuilder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
38 39 40 41 42 |
# File 'lib/rspec_tracer/reporters/payload_builder.rb', line 38 def initialize(snapshot:, run_metadata:, generated_at: nil) @snapshot = snapshot @run_metadata = || {} @generated_at = generated_at || ::Time.now.utc end |
Class Method Details
.build(snapshot:, run_metadata:, generated_at: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal helper for the tracer pipeline.
32 33 34 |
# File 'lib/rspec_tracer/reporters/payload_builder.rb', line 32 def self.build(snapshot:, run_metadata:, generated_at: nil) new(snapshot: snapshot, run_metadata: , generated_at: generated_at).build end |
Instance Method Details
#build ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rspec_tracer/reporters/payload_builder.rb', line 46 def build { schema_version: SCHEMA_VERSION, run_id: @snapshot.run_id, generated_at: stringify_time(@generated_at), summary: summary_block, reports: { all_examples: all_examples_report, duplicate_examples: duplicate_examples_report, flaky_examples: flaky_examples_report, examples_dependency: examples_dependency_report, files_dependency: files_dependency_report } } end |