Class: Fontisan::Models::CollectionValidationReport

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontisan/models/collection_validation_report.rb

Overview

CollectionValidationReport aggregates validation results for all fonts in a TTC/OTC/dfont collection.

Provides collection-level summary statistics and per-font validation details with clear formatting.

Instance Method Summary collapse

Instance Method Details

#add_font_report(font_report) ⇒ void

This method returns an undefined value.

Add a font report to the collection

Parameters:

  • font_report (FontReport)

    The font report to add



34
35
36
37
38
39
40
# File 'lib/fontisan/models/collection_validation_report.rb', line 34

def add_font_report(font_report)
  font_reports << font_report
  # Mark that we're no longer using the default value
  value_set_for(:font_reports)
  # Update overall validity
  self.valid = valid && font_report.report.valid?
end

#overall_statusString

Get overall validation status for the collection

Returns:

  • (String)

    “valid”, “invalid”, or “valid_with_warnings”



45
46
47
48
49
50
51
52
# File 'lib/fontisan/models/collection_validation_report.rb', line 45

def overall_status
  return "invalid" unless font_reports.all? { |fr| fr.report.valid? }
  return "valid_with_warnings" if font_reports.any? do |fr|
    fr.report.has_warnings?
  end

  "valid"
end

#text_summaryString

Generate text summary with collection header and per-font sections

Returns:

  • (String)

    Formatted validation report



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fontisan/models/collection_validation_report.rb', line 57

def text_summary
  lines = []
  lines << "Collection: #{collection_path}"
  lines << "Type: #{collection_type}"
  lines << "Fonts: #{num_fonts}"
  lines << ""
  lines << "Summary:"
  lines << "  Total Errors: #{total_errors}"
  lines << "  Total Warnings: #{total_warnings}"
  lines << "  Total Info: #{total_info}"

  if font_reports.any?
    lines << ""
    font_reports.each do |font_report|
      lines << "=== Font #{font_report.font_index}: #{font_report.font_name} ==="
      # Indent each line of the font's report
      font_lines = font_report.report.text_summary.split("\n")
      lines.concat(font_lines)
      lines << "" unless font_report == font_reports.last
    end
  end

  lines.join("\n")
end

#total_errorsInteger

Calculate total errors across all fonts

Returns:

  • (Integer)

    Total error count



85
86
87
# File 'lib/fontisan/models/collection_validation_report.rb', line 85

def total_errors
  font_reports.sum { |fr| fr.report.summary.errors }
end

#total_infoInteger

Calculate total info messages across all fonts

Returns:

  • (Integer)

    Total info count



99
100
101
# File 'lib/fontisan/models/collection_validation_report.rb', line 99

def total_info
  font_reports.sum { |fr| fr.report.summary.info }
end

#total_warningsInteger

Calculate total warnings across all fonts

Returns:

  • (Integer)

    Total warning count



92
93
94
# File 'lib/fontisan/models/collection_validation_report.rb', line 92

def total_warnings
  font_reports.sum { |fr| fr.report.summary.warnings }
end