Class: Fontisan::Models::ValidationReport
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Fontisan::Models::ValidationReport
- Defined in:
- lib/fontisan/models/validation_report.rb
Overview
ValidationReport represents the result of font validation
This model encapsulates all validation results including error, warning, and informational messages. It supports serialization to YAML, JSON, and plain text formats for different use cases.
Defined Under Namespace
Instance Method Summary collapse
-
#add_error(category, message, location = nil) ⇒ void
Add an error to the report.
-
#add_info(category, message, location = nil) ⇒ void
Add an info message to the report.
-
#add_warning(category, message, location = nil) ⇒ void
Add a warning to the report.
-
#errors ⇒ Array<Issue>
Get all error issues.
-
#has_errors? ⇒ Boolean
Check if report has errors.
-
#has_warnings? ⇒ Boolean
Check if report has warnings.
-
#info_issues ⇒ Array<Issue>
Get all info issues.
-
#text_summary ⇒ String
Get a text summary of the validation.
-
#warnings ⇒ Array<Issue>
Get all warning issues.
Instance Method Details
#add_error(category, message, location = nil) ⇒ void
This method returns an undefined value.
Add an error to the report
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/fontisan/models/validation_report.rb', line 93 def add_error(category, , location = nil) issues << Issue.new( severity: "error", category: category, message: , location: location, ) summary.errors += 1 self.valid = false end |
#add_info(category, message, location = nil) ⇒ void
This method returns an undefined value.
Add an info message to the report
126 127 128 129 130 131 132 133 134 |
# File 'lib/fontisan/models/validation_report.rb', line 126 def add_info(category, , location = nil) issues << Issue.new( severity: "info", category: category, message: , location: location, ) summary.info += 1 end |
#add_warning(category, message, location = nil) ⇒ void
This method returns an undefined value.
Add a warning to the report
110 111 112 113 114 115 116 117 118 |
# File 'lib/fontisan/models/validation_report.rb', line 110 def add_warning(category, , location = nil) issues << Issue.new( severity: "warning", category: category, message: , location: location, ) summary.warnings += 1 end |
#errors ⇒ Array<Issue>
Get all error issues
139 140 141 |
# File 'lib/fontisan/models/validation_report.rb', line 139 def errors issues.select { |issue| issue.severity == "error" } end |
#has_errors? ⇒ Boolean
Check if report has errors
160 161 162 |
# File 'lib/fontisan/models/validation_report.rb', line 160 def has_errors? summary.errors.positive? end |
#has_warnings? ⇒ Boolean
Check if report has warnings
167 168 169 |
# File 'lib/fontisan/models/validation_report.rb', line 167 def has_warnings? summary.warnings.positive? end |
#info_issues ⇒ Array<Issue>
Get all info issues
153 154 155 |
# File 'lib/fontisan/models/validation_report.rb', line 153 def info_issues issues.select { |issue| issue.severity == "info" } end |
#text_summary ⇒ String
Get a text summary of the validation
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/fontisan/models/validation_report.rb', line 174 def text_summary status = valid ? "VALID" : "INVALID" lines = [] lines << "Font: #{font_path}" lines << "Status: #{status}" lines << "" lines << "Summary:" lines << " Errors: #{summary.errors}" lines << " Warnings: #{summary.warnings}" lines << " Info: #{summary.info}" if issues.any? lines << "" lines << "Issues:" issues.each do |issue| severity_marker = case issue.severity when "error" then "[ERROR]" when "warning" then "[WARN]" when "info" then "[INFO]" end location_info = issue.location ? " (#{issue.location})" : "" lines << " #{severity_marker} #{issue.category}: #{issue.}#{location_info}" end end lines.join("\n") end |
#warnings ⇒ Array<Issue>
Get all warning issues
146 147 148 |
# File 'lib/fontisan/models/validation_report.rb', line 146 def warnings issues.select { |issue| issue.severity == "warning" } end |