Class: Fontisan::Commands::ValidateCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Fontisan::Commands::ValidateCommand
- Defined in:
- lib/fontisan/commands/validate_command.rb
Overview
ValidateCommand provides CLI interface for font validation
This command validates fonts against quality checks, structural integrity, and OpenType specification compliance. It supports different validation profiles and output formats, with ftxvalidator-compatible options.
Instance Method Summary collapse
-
#initialize(input:, profile: nil, exclude: [], output: nil, format: :text, full_report: false, summary_report: false, table_report: false, verbose: false, suppress_warnings: false, return_value_results: false) ⇒ ValidateCommand
constructor
Initialize validate command.
-
#run ⇒ Integer
Run the validation command.
Constructor Details
#initialize(input:, profile: nil, exclude: [], output: nil, format: :text, full_report: false, summary_report: false, table_report: false, verbose: false, suppress_warnings: false, return_value_results: false) ⇒ ValidateCommand
Initialize validate command
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fontisan/commands/validate_command.rb', line 40 def initialize( input:, profile: nil, exclude: [], output: nil, format: :text, full_report: false, summary_report: false, table_report: false, verbose: false, suppress_warnings: false, return_value_results: false ) @input = input @profile = profile || :default @exclude = exclude @output = output @format = format @full_report = full_report @summary_report = summary_report @table_report = table_report @verbose = verbose @suppress_warnings = suppress_warnings @return_value_results = return_value_results end |
Instance Method Details
#run ⇒ Integer
Run the validation command
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/fontisan/commands/validate_command.rb', line 69 def run # Load font with appropriate mode profile_config = Validators::ProfileLoader.profile_info(@profile) unless profile_config puts "Error: Unknown profile '#{@profile}'" unless @suppress_warnings return 1 end mode = profile_config[:loading_mode].to_sym font = FontLoader.load(@input, mode: mode) # Select validator validator = Validators::ProfileLoader.load(@profile) # Run validation report = validator.validate(font) # Filter excluded checks if specified if @exclude.any? report.check_results.reject! { |cr| @exclude.include?(cr.check_id) } end # Generate output output = generate_output(report) # Write to file or stdout if @output File.write(@output, output) puts "Validation report written to #{@output}" if @verbose && !@suppress_warnings else puts output unless @suppress_warnings end # Return exit code exit_code(report) rescue => e puts "Error: #{e.}" unless @suppress_warnings puts e.backtrace.join("\n") if @verbose && !@suppress_warnings 1 end |