Class: Henitai::CompositeProgressReporter
- Inherits:
-
Object
- Object
- Henitai::CompositeProgressReporter
- Defined in:
- lib/henitai/composite_progress_reporter.rb,
sig/henitai.rbs
Overview
Fans a single #progress callback out to several observers so the execution engines keep exactly one progress hook. Used to run the terminal reporter and the checkpoint writer side by side.
Class Method Summary collapse
- .checkpoint_for(config, source_provider, full_run) ⇒ Object
-
.for(config:, source_provider:, full_run:) ⇒ Object?
Assembles the active progress reporters for a run: the terminal reporter when terminal output is on, and the checkpoint writer when enabled and a file report (json/html) is configured.
- .reporter?(config, name) ⇒ Boolean
- .terminal_for(config) ⇒ Object
Instance Method Summary collapse
-
#initialize(reporters) ⇒ CompositeProgressReporter
constructor
A new instance of CompositeProgressReporter.
- #progress(mutant, scenario_result: nil) ⇒ void
Constructor Details
#initialize(reporters) ⇒ CompositeProgressReporter
Returns a new instance of CompositeProgressReporter.
34 35 36 |
# File 'lib/henitai/composite_progress_reporter.rb', line 34 def initialize(reporters) @reporters = reporters.compact end |
Class Method Details
.checkpoint_for(config, source_provider, full_run) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/henitai/composite_progress_reporter.rb', line 23 def self.checkpoint_for(config, source_provider, full_run) return unless config.respond_to?(:checkpoint_enabled) && config.checkpoint_enabled return unless reporter?(config, "json") || reporter?(config, "html") CheckpointReporter.new(config:, source_provider:, authoritative: full_run) end |
.for(config:, source_provider:, full_run:) ⇒ Object?
Assembles the active progress reporters for a run: the terminal reporter when terminal output is on, and the checkpoint writer when enabled and a file report (json/html) is configured. Returns a single reporter when only one is active, the composite when several are, or nil when none are.
12 13 14 15 16 17 |
# File 'lib/henitai/composite_progress_reporter.rb', line 12 def self.for(config:, source_provider:, full_run:) active = [terminal_for(config), checkpoint_for(config, source_provider, full_run)].compact return active.first if active.one? active.empty? ? nil : new(active) end |
.reporter?(config, name) ⇒ Boolean
30 31 32 |
# File 'lib/henitai/composite_progress_reporter.rb', line 30 def self.reporter?(config, name) Array(config.reporters).map(&:to_s).include?(name) end |