Class: Ucode::Glyphs::RealFonts::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/real_fonts/writer.rb

Overview

Persists a FontCoverageReport as a JSON file under ‘output/font_coverage/`. One file per audited face; the filename is derived from the report’s ‘source_file` so the source and the report are trivially correlated.

Constant Summary collapse

DEFAULT_OUTPUT_DIR =
"font_coverage"

Instance Method Summary collapse

Constructor Details

#initialize(output_root) ⇒ Writer

Returns a new instance of Writer.

Parameters:

  • output_root (Pathname, String)

    parent directory; the ‘font_coverage/` subdirectory is created inside it.



20
21
22
# File 'lib/ucode/glyphs/real_fonts/writer.rb', line 20

def initialize(output_root)
  @output_root = Pathname(output_root)
end

Instance Method Details

#write(report) ⇒ Pathname

Returns absolute path of the written file.

Parameters:

Returns:

  • (Pathname)

    absolute path of the written file



26
27
28
29
30
31
# File 'lib/ucode/glyphs/real_fonts/writer.rb', line 26

def write(report)
  path = target_path(report)
  path.dirname.mkpath
  path.write("#{JSON.pretty_generate(report.to_hash)}\n")
  path
end