Class: Fontisan::Commands::ValidateCollectionCommand
- Inherits:
-
Object
- Object
- Fontisan::Commands::ValidateCollectionCommand
- Defined in:
- lib/fontisan/commands/validate_collection_command.rb
Overview
Validates the structural integrity of a TTC/OTC/dfont collection (TODO 74). Complements ValidateCommand, which runs profile-based checks against a single face. This command runs collection-level checks: face count, per-face glyph cap, optional cmap-union size.
Returns an integer exit code (0 = all checks passed, 1 = any check failed) suitable for use as the CLI's exit status.
The command is intentionally narrow: it does not subclass BaseCommand (which eagerly loads a single font at construction time) because the input here is a collection, not a single face. It owns its own loading via Fontisan::Collection::Reader.
Defined Under Namespace
Classes: Check
Constant Summary collapse
- DEFAULT_MAX_GLYPHS =
65_535
Instance Attribute Summary collapse
-
#checks ⇒ Array<Check>
readonly
The most recent run's checks.
Instance Method Summary collapse
-
#initialize(input:, expected_faces: nil, max_glyphs: DEFAULT_MAX_GLYPHS, expected_cmap_union: nil) ⇒ ValidateCollectionCommand
constructor
A new instance of ValidateCollectionCommand.
-
#run ⇒ Integer
0 if all checks passed, 1 otherwise.
Constructor Details
#initialize(input:, expected_faces: nil, max_glyphs: DEFAULT_MAX_GLYPHS, expected_cmap_union: nil) ⇒ ValidateCollectionCommand
Returns a new instance of ValidateCollectionCommand.
41 42 43 44 45 46 47 |
# File 'lib/fontisan/commands/validate_collection_command.rb', line 41 def initialize(input:, expected_faces: nil, max_glyphs: DEFAULT_MAX_GLYPHS, expected_cmap_union: nil) @input = input @expected_faces = expected_faces @max_glyphs = max_glyphs @expected_cmap_union = expected_cmap_union end |
Instance Attribute Details
#checks ⇒ Array<Check> (readonly)
Returns the most recent run's checks.
63 64 65 |
# File 'lib/fontisan/commands/validate_collection_command.rb', line 63 def checks @checks end |
Instance Method Details
#run ⇒ Integer
Returns 0 if all checks passed, 1 otherwise.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fontisan/commands/validate_collection_command.rb', line 50 def run reader = Collection::Reader.open(@input) @checks = [ check_face_count(reader), check_glyph_cap(reader), check_cmap_union(reader), ].compact render_report(reader) @checks.all?(&:passed?) ? 0 : 1 end |