Class: Ucode::Audit::Context
- Inherits:
-
Object
- Object
- Ucode::Audit::Context
- Defined in:
- lib/ucode/audit/context.rb
Overview
Value object carrying everything an extractor needs to do its job.
Extractors never reach back into AuditCommand state — they read exclusively from the Context. Shared derived data (codepoints, UCD baseline, source format) is memoized here so multiple extractors don't recompute it.
ucode deltas vs fontisan's Context:
- Drops
cldrand the entire CLDR resolution path (out of scope). - Replaces fontisan's
ucdmemoizer withbaseline, a struct carrying version + database + metadata. - Adds optional
rendererfor--with-glyphsmode (nil otherwise).
Instance Attribute Summary collapse
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#font_index ⇒ Object
readonly
Returns the value of attribute font_index.
-
#font_path ⇒ Object
readonly
Returns the value of attribute font_path.
-
#num_fonts_in_source ⇒ Object
readonly
Returns the value of attribute num_fonts_in_source.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
-
#all_codepoints? ⇒ Boolean
True when the user asked for every codepoint (including unassigned) in the report's
codepointsfield. -
#baseline ⇒ Baseline
Pre-resolved baseline (UCD version + database + metadata).
-
#codepoints ⇒ Array<Integer>
Codepoints the font's cmap actually maps.
-
#initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:, renderer: nil, reference: nil) ⇒ Context
constructor
A new instance of Context.
-
#reference ⇒ CoverageReference?
The CoverageReference the audit compares against.
-
#source_format ⇒ String?
Detected source format string ("ttf", "otf", "ttc", ...).
-
#with_glyphs? ⇒ Boolean
True when glyph rendering is requested (--with-glyphs).
Constructor Details
#initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:, renderer: nil, reference: nil) ⇒ Context
Returns a new instance of Context.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ucode/audit/context.rb', line 48 def initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:, renderer: nil, reference: nil) @font = font @font_path = font_path @font_index = font_index @num_fonts_in_source = num_fonts_in_source @options = @renderer = renderer @reference_override = reference end |
Instance Attribute Details
#font ⇒ Object (readonly)
Returns the value of attribute font.
32 33 34 |
# File 'lib/ucode/audit/context.rb', line 32 def font @font end |
#font_index ⇒ Object (readonly)
Returns the value of attribute font_index.
32 33 34 |
# File 'lib/ucode/audit/context.rb', line 32 def font_index @font_index end |
#font_path ⇒ Object (readonly)
Returns the value of attribute font_path.
32 33 34 |
# File 'lib/ucode/audit/context.rb', line 32 def font_path @font_path end |
#num_fonts_in_source ⇒ Object (readonly)
Returns the value of attribute num_fonts_in_source.
32 33 34 |
# File 'lib/ucode/audit/context.rb', line 32 def num_fonts_in_source @num_fonts_in_source end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
32 33 34 |
# File 'lib/ucode/audit/context.rb', line 32 def @options end |
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
32 33 34 |
# File 'lib/ucode/audit/context.rb', line 32 def renderer @renderer end |
Instance Method Details
#all_codepoints? ⇒ Boolean
True when the user asked for every codepoint (including unassigned)
in the report's codepoints field.
94 95 96 |
# File 'lib/ucode/audit/context.rb', line 94 def all_codepoints? @options[:all_codepoints] == true end |
#baseline ⇒ Baseline
Pre-resolved baseline (UCD version + database + metadata).
Memoized. When resolution fails, returns a Baseline with a
warning and nil database so extractors can degrade gracefully.
69 70 71 |
# File 'lib/ucode/audit/context.rb', line 69 def baseline @baseline ||= resolve_baseline end |
#codepoints ⇒ Array<Integer>
Codepoints the font's cmap actually maps. Memoized.
61 62 63 |
# File 'lib/ucode/audit/context.rb', line 61 def codepoints @codepoints ||= extract_codepoints end |
#reference ⇒ CoverageReference?
The Ucode::Audit::CoverageReference the audit compares against. Defaults to a UcdOnlyReference built from the resolved baseline database. When the caller supplied a reference at construction (typically a UniversalSetReference), that one is used verbatim. Memoized.
81 82 83 |
# File 'lib/ucode/audit/context.rb', line 81 def reference @reference ||= @reference_override || build_default_reference end |
#source_format ⇒ String?
Detected source format string ("ttf", "otf", "ttc", ...). Memoized.
87 88 89 |
# File 'lib/ucode/audit/context.rb', line 87 def source_format @source_format ||= Fontisan::FontLoader.detect_format(@font_path)&.to_s end |
#with_glyphs? ⇒ Boolean
True when glyph rendering is requested (--with-glyphs).
100 101 102 |
# File 'lib/ucode/audit/context.rb', line 100 def with_glyphs? @options[:with_glyphs] == true && !@renderer.nil? end |