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 ‘cldr` and the entire CLDR resolution path (out of scope).
-
Replaces fontisan’s ‘ucd` memoizer with `baseline`, a struct carrying version + database + metadata.
-
Adds optional ‘renderer` for `–with-glyphs` mode (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 ‘codepoints` field.
-
#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) ⇒ Context
constructor
A new instance of Context.
-
#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) ⇒ Context
Returns a new instance of Context.
42 43 44 45 46 47 48 49 50 |
# File 'lib/ucode/audit/context.rb', line 42 def initialize(font:, font_path:, font_index:, num_fonts_in_source:, options:, renderer: nil) @font = font @font_path = font_path @font_index = font_index @num_fonts_in_source = num_fonts_in_source @options = @renderer = renderer 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.
75 76 77 |
# File 'lib/ucode/audit/context.rb', line 75 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.
62 63 64 |
# File 'lib/ucode/audit/context.rb', line 62 def baseline @baseline ||= resolve_baseline end |
#codepoints ⇒ Array<Integer>
Codepoints the font’s cmap actually maps. Memoized.
54 55 56 |
# File 'lib/ucode/audit/context.rb', line 54 def codepoints @codepoints ||= extract_codepoints end |
#source_format ⇒ String?
Detected source format string (“ttf”, “otf”, “ttc”, …). Memoized.
68 69 70 |
# File 'lib/ucode/audit/context.rb', line 68 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).
81 82 83 |
# File 'lib/ucode/audit/context.rb', line 81 def with_glyphs? @options[:with_glyphs] == true && !@renderer.nil? end |