module NoirOutputFiles
Overview
Process-wide registry of -o file handles, one per output path.
A standalone type, deliberately, rather than a @@ on OutputBuilder:
Crystal gives every subclass its own copy of an inherited class
variable. The @@prepared_output_files set this replaces therefore
tracked "already truncated?" separately per builder class, so the second
builder to write a given run's -o file re-opened it in "w" and erased
what the first had put there. In diff mode that silently ate the
✚ Added (n) section header: OutputBuilderDiff writes the header, then
the OutputBuilderCommon it delegates to truncates the file out from under
it. One registry, keyed by path only, gives every builder in the run the
same handle — truncate once on open, append from then on.
Defined in:
models/output_builder.crClass Method Summary
-
.handle(path : String) : File
Opened lazily so a builder constructed with an
-opath but never written to (the format never emits, or the run has no results) doesn't leave an empty file behind. -
.reset : Nil
Specs write to a tempname, read it back, then delete it; without this a later example reusing a path would keep writing to the stale handle.
Class Method Detail
Opened lazily so a builder constructed with an -o path but never
written to (the format never emits, or the run has no results) doesn't
leave an empty file behind.
Specs write to a tempname, read it back, then delete it; without this a later example reusing a path would keep writing to the stale handle.