Class: SvgConform::Compatibility::ComparisonResult
- Inherits:
-
Object
- Object
- SvgConform::Compatibility::ComparisonResult
- Defined in:
- lib/svg_conform/compatibility/comparison_result.rb
Overview
Value object representing the results of a compatibility comparison
Instance Attribute Summary collapse
-
#content_comparison ⇒ Object
readonly
Returns the value of attribute content_comparison.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#svg_conform_result ⇒ Object
readonly
Returns the value of attribute svg_conform_result.
-
#svgcheck_result ⇒ Object
readonly
Returns the value of attribute svgcheck_result.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#validation_comparison ⇒ Object
readonly
Returns the value of attribute validation_comparison.
-
#xml_equivalence ⇒ Object
readonly
Returns the value of attribute xml_equivalence.
Instance Method Summary collapse
- #basic_repair? ⇒ Boolean
- #basic_validation? ⇒ Boolean
- #compatibility_score ⇒ Object
- #content_equivalence_score ⇒ Object
- #error_count ⇒ Object
-
#initialize(filename:, type:, **options) ⇒ ComparisonResult
constructor
A new instance of ComparisonResult.
- #issues_fixed ⇒ Object
- #remediations_applied ⇒ Object
- #semantic_repair? ⇒ Boolean
- #semantic_validation? ⇒ Boolean
- #successful_remediation? ⇒ Boolean
- #svg_conform_valid? ⇒ Boolean
- #svgcheck_valid? ⇒ Boolean
- #to_h ⇒ Object
- #validity_match? ⇒ Boolean
- #xml_differences ⇒ Object
- #xml_equivalent? ⇒ Boolean
- #xml_error ⇒ Object
Constructor Details
#initialize(filename:, type:, **options) ⇒ ComparisonResult
Returns a new instance of ComparisonResult.
10 11 12 13 14 15 16 17 18 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 10 def initialize(filename:, type:, **) @filename = filename @type = type @validation_comparison = [:validation_comparison] @content_comparison = [:content_comparison] @xml_equivalence = [:xml_equivalence] @svg_conform_result = [:svg_conform_result] @svgcheck_result = [:svgcheck_result] end |
Instance Attribute Details
#content_comparison ⇒ Object (readonly)
Returns the value of attribute content_comparison.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def content_comparison @content_comparison end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def filename @filename end |
#svg_conform_result ⇒ Object (readonly)
Returns the value of attribute svg_conform_result.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def svg_conform_result @svg_conform_result end |
#svgcheck_result ⇒ Object (readonly)
Returns the value of attribute svgcheck_result.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def svgcheck_result @svgcheck_result end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def type @type end |
#validation_comparison ⇒ Object (readonly)
Returns the value of attribute validation_comparison.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def validation_comparison @validation_comparison end |
#xml_equivalence ⇒ Object (readonly)
Returns the value of attribute xml_equivalence.
7 8 9 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 7 def xml_equivalence @xml_equivalence end |
Instance Method Details
#basic_repair? ⇒ Boolean
32 33 34 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 32 def basic_repair? @type == :basic_repair end |
#basic_validation? ⇒ Boolean
28 29 30 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 28 def basic_validation? @type == :basic_validation end |
#compatibility_score ⇒ Object
36 37 38 39 40 41 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 36 def compatibility_score return 0.0 unless @validation_comparison raw_score = @validation_comparison[:compatibility_score] || 0.0 raw_score * 100.0 end |
#content_equivalence_score ⇒ Object
65 66 67 68 69 70 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 65 def content_equivalence_score return 0.0 unless @content_comparison raw_score = @content_comparison[:semantic_equivalence] || 0.0 raw_score * 100.0 end |
#error_count ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 112 def error_count if semantic_validation? || semantic_repair? # For semantic results, we'd need to extract from validation_comparison 0 else # For basic repair mode, count initial validation errors svg_conform_errors = if @svg_conform_result&.initial_validation @svg_conform_result.initial_validation.failed_requirements.length else 0 end svgcheck_errors = @svgcheck_result&.errors&.total_count || 0 svg_conform_errors + svgcheck_errors end end |
#issues_fixed ⇒ Object
100 101 102 103 104 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 100 def issues_fixed return 0 unless basic_repair? @svg_conform_result&.issues_fixed || 0 end |
#remediations_applied ⇒ Object
106 107 108 109 110 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 106 def remediations_applied return 0 unless basic_repair? @svg_conform_result&.remediations_applied || 0 end |
#semantic_repair? ⇒ Boolean
24 25 26 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 24 def semantic_repair? @type == :semantic_repair end |
#semantic_validation? ⇒ Boolean
20 21 22 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 20 def semantic_validation? @type == :semantic_validation end |
#successful_remediation? ⇒ Boolean
90 91 92 93 94 95 96 97 98 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 90 def successful_remediation? if semantic_repair? svg_conform_valid? elsif basic_repair? @svg_conform_result&.success? || false else false end end |
#svg_conform_valid? ⇒ Boolean
49 50 51 52 53 54 55 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 49 def svg_conform_valid? if semantic_validation? || semantic_repair? @validation_comparison&.dig(:overall_validity, :svg_conform) || false else @svg_conform_result&.success? || false end end |
#svgcheck_valid? ⇒ Boolean
57 58 59 60 61 62 63 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 57 def svgcheck_valid? if semantic_validation? || semantic_repair? @validation_comparison&.dig(:overall_validity, :svgcheck) || false else @svgcheck_result&.valid || false end end |
#to_h ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 130 def to_h { filename: @filename, type: @type, compatibility_score: compatibility_score, validity_match: validity_match?, svg_conform_valid: svg_conform_valid?, svgcheck_valid: svgcheck_valid?, content_equivalence_score: content_equivalence_score, xml_equivalent: xml_equivalent?, successful_remediation: successful_remediation?, issues_fixed: issues_fixed, remediations_applied: remediations_applied, } end |
#validity_match? ⇒ Boolean
43 44 45 46 47 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 43 def validity_match? return false unless @validation_comparison @validation_comparison.dig(:overall_validity, :match) || false end |
#xml_differences ⇒ Object
78 79 80 81 82 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 78 def xml_differences return [] unless @xml_equivalence @xml_equivalence[:differences] || [] end |
#xml_equivalent? ⇒ Boolean
72 73 74 75 76 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 72 def xml_equivalent? return false unless @xml_equivalence @xml_equivalence[:xml_equivalent] || false end |
#xml_error ⇒ Object
84 85 86 87 88 |
# File 'lib/svg_conform/compatibility/comparison_result.rb', line 84 def xml_error return nil unless @xml_equivalence @xml_equivalence[:error] end |