Class: RSpecTracer::Reporters::Registry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_tracer/reporters/registry.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.

Orchestrates reporter emission at finalize-time. Called from ‘RSpecTracer#run_exit_tasks` once the Engine has persisted its Snapshot (architectural decision (a): wire from run_exit_tasks, not Engine-internal). Each configured reporter gets an isolated rescue; a buggy reporter warns + continues, never propagates a non-zero exit into the user’s test suite.

Reporter resolution:

- Configuration#reporters returns `[[name_or_class, opts], ...]`
  when the user called `add_reporter`; `nil` otherwise.
- When nil, falls back to `DEFAULTS` (`[:terminal, :json]`).
- Symbol names resolve via `BUILT_INS` to in-tree reporter
  classes. Class values pass through as-is (custom reporters
  conforming to `Reporters::Base`).
- Unknown symbols raise `ArgumentError` at emit time; the DSL
  validates eagerly, so this is the safety net for programmatic
  callers.

Constant Summary collapse

BUILT_INS =

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.

Symbol -> lazy class-name mapping. Strings (not Class constants) so the require order doesn’t force load of reporter classes when the Registry module itself is loaded - matches how ‘storage_backend`’s Configuration DSL defers backend resolution.

{
  terminal: 'RSpecTracer::Reporters::TerminalReporter',
  json: 'RSpecTracer::Reporters::JsonReporter',
  html: 'RSpecTracer::Reporters::HtmlReporter'
}.freeze
DEFAULTS =

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.

%i[terminal json html].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration:) ⇒ Registry

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.



49
50
51
# File 'lib/rspec_tracer/reporters/registry.rb', line 49

def initialize(configuration:)
  @configuration = configuration
end

Class Method Details

.emit_all(configuration:, snapshot:, report_dir:, run_metadata:) ⇒ 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.



41
42
43
44
45
# File 'lib/rspec_tracer/reporters/registry.rb', line 41

def self.emit_all(configuration:, snapshot:, report_dir:, run_metadata:)
  new(configuration: configuration).emit_all(
    snapshot: snapshot, report_dir: report_dir, run_metadata: 
  )
end

Instance Method Details

#emit_all(snapshot:, report_dir:, run_metadata:) ⇒ 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.



55
56
57
58
59
60
61
# File 'lib/rspec_tracer/reporters/registry.rb', line 55

def emit_all(snapshot:, report_dir:, run_metadata:)
  entries = resolve_entries
  return [] if entries.empty?
  return [] if empty_snapshot?(snapshot)

  entries.map { |klass, opts| emit_one(klass, opts, snapshot, report_dir, ) }
end