Class: Ucode::Audit::UcdOnlyReference
- Inherits:
-
CoverageReference
- Object
- CoverageReference
- Ucode::Audit::UcdOnlyReference
- Defined in:
- lib/ucode/audit/ucd_only_reference.rb
Overview
CoverageReference backed by a Database. The "legacy" reference: derives the assigned codepoint set from block ranges alone, with no per-codepoint provenance.
Used by the audit pipeline when no universal-set manifest is
available (or the user explicitly opts out via
--reference-universal-set=none). All audits before TODO 25
behaved this way.
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
-
#block_name_for(codepoint) ⇒ String?
Block name (verbatim Unicode identifier, e.g. "Basic_Latin") the codepoint falls under, or nil if it isn't in any known block.
-
#entries_for_block(block_id) ⇒ Array<Entry>
Every assigned codepoint in the block, with tier + source attached when the reference carries provenance.
-
#include?(codepoint) ⇒ Boolean
True if the codepoint is in the reference set.
-
#initialize(database:) ⇒ UcdOnlyReference
constructor
A new instance of UcdOnlyReference.
-
#kind ⇒ Symbol
:ucd.
-
#provenance_for(_codepoints) ⇒ nil
UCD-only references carry no provenance.
-
#reference_id ⇒ String
Stable identifier for the reference, embedded in audit reports so consumers can detect drift.
Constructor Details
#initialize(database:) ⇒ UcdOnlyReference
Returns a new instance of UcdOnlyReference.
16 17 18 19 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 16 def initialize(database:) super() @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
21 22 23 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 21 def database @database end |
Instance Method Details
#block_name_for(codepoint) ⇒ String?
Block name (verbatim Unicode identifier, e.g. "Basic_Latin") the codepoint falls under, or nil if it isn't in any known block. Used by BlockAggregator to group a font's cmap by block without needing direct access to the underlying Database.
36 37 38 39 40 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 36 def block_name_for(codepoint) return nil if @database.nil? @database.lookup_block(codepoint) end |
#entries_for_block(block_id) ⇒ Array<Entry>
Every assigned codepoint in the block, with tier + source attached when the reference carries provenance.
43 44 45 46 47 48 49 50 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 43 def entries_for_block(block_id) return [] if @database.nil? ranges = @database.block_ranges_by_name(block_id) return [] if ranges.nil? || ranges.empty? ranges.flat_map { |r| (r) } end |
#include?(codepoint) ⇒ Boolean
Returns true if the codepoint is in the reference set.
29 30 31 32 33 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 29 def include?(codepoint) return false if @database.nil? !@database.lookup_block(codepoint).nil? end |
#kind ⇒ Symbol
Returns :ucd.
24 25 26 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 24 def kind :ucd end |
#provenance_for(_codepoints) ⇒ nil
UCD-only references carry no provenance. Returning nil signals
"do not populate missing_codepoint_provenance" so the audit
report preserves the legacy wire shape.
63 64 65 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 63 def provenance_for(_codepoints) nil end |
#reference_id ⇒ String
Stable identifier for the reference, embedded in audit reports so consumers can detect drift. Examples:
"ucd:17.0.0"
"universal-set:17.0.0:abc12345"
53 54 55 56 |
# File 'lib/ucode/audit/ucd_only_reference.rb', line 53 def reference_id version = @database&.ucd_version || "unknown" "ucd:#{version}" end |