Class: Ucode::Repo::Writers::NamedSequencesWriter
- Inherits:
-
Object
- Object
- Ucode::Repo::Writers::NamedSequencesWriter
- Includes:
- AtomicWrites
- Defined in:
- lib/ucode/repo/writers/named_sequences_writer.rb
Overview
Writes one file per named sequence under
output/named_sequences/<slug>.json. Empty input writes nothing.
One of the eight per-concern writers split out from AggregateWriter — see Candidate 5 of the 2026-06-29 review.
Instance Method Summary collapse
-
#initialize(output_root:, named_sequences:) ⇒ NamedSequencesWriter
constructor
A new instance of NamedSequencesWriter.
-
#write ⇒ Integer
Number of named-sequence files written.
Methods included from AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(output_root:, named_sequences:) ⇒ NamedSequencesWriter
Returns a new instance of NamedSequencesWriter.
19 20 21 22 |
# File 'lib/ucode/repo/writers/named_sequences_writer.rb', line 19 def initialize(output_root:, named_sequences:) @output_root = output_root @named_sequences = named_sequences end |
Instance Method Details
#write ⇒ Integer
Returns number of named-sequence files written.
25 26 27 28 29 30 31 32 33 |
# File 'lib/ucode/repo/writers/named_sequences_writer.rb', line 25 def write return 0 if @named_sequences.nil? || @named_sequences.empty? dir = Pathname(@output_root).join("named_sequences") @named_sequences.sum do |ns| path = dir.join("#{slug_for(ns)}.json") write_atomic(path, ns.to_json(pretty: true)) ? 1 : 0 end end |