Class: Ucode::CodeChart::BatchRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/code_chart/batch_runner.rb

Overview

Multi-block orchestration: drives one Writer per gap block, enforces per-block idempotency, isolates per-block failures.

Composes four orthogonal concerns:

* {Fetcher}      — owns PDF download + cache + integrity check
* {Writer}       — owns one block's extraction + disk write
* {GapAnalyzer}  — owns "which codepoints to extract per block"
* {SkipChecker}  — owns "should this block be skipped" (this file)

Each concern is replaceable; BatchRunner itself is a pure iterator + aggregator. Adding a new "skip if X" rule = one method on SkipChecker, one entry in the predicate chain.

Defined Under Namespace

Classes: Aggregate, BlockSummary, SkipChecker

Instance Method Summary collapse

Constructor Details

#initialize(output_root:, ucd_version:, fetcher:, writer_class: Writer, skip_checker_class: SkipChecker) ⇒ BatchRunner

Returns a new instance of BatchRunner.

Parameters:

  • output_root (Pathname, String)

    root for per-block dirs

  • ucd_version (String)
  • fetcher (Fetcher)
  • writer_class (Class) (defaults to: Writer)

    injectable for tests

  • skip_checker_class (Class) (defaults to: SkipChecker)

    injectable for tests



51
52
53
54
55
56
57
58
# File 'lib/ucode/code_chart/batch_runner.rb', line 51

def initialize(output_root:, ucd_version:, fetcher:,
               writer_class: Writer, skip_checker_class: SkipChecker)
  @output_root = Pathname.new(output_root)
  @ucd_version = ucd_version
  @fetcher = fetcher
  @writer_class = writer_class
  @skip_checker_class = skip_checker_class
end

Instance Method Details

#run(gap_analyzer:, blocks:) {|summary| ... } ⇒ Aggregate

Parameters:

Yield Parameters:

Returns:



64
65
66
67
68
69
70
71
72
# File 'lib/ucode/code_chart/batch_runner.rb', line 64

def run(gap_analyzer:, blocks:)
  summaries = []
  gap_analyzer.each_block_gap do |gap|
    summary = process_gap(gap, blocks.fetch(gap.block_id))
    summaries << summary
    yield summary if block_given?
  end
  build_aggregate(summaries)
end