Class: SvgConform::ExternalCheckers::Svgcheck::CompatibilityEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/svg_conform/external_checkers/svgcheck/compatibility_engine.rb

Overview

Compatibility engine for matching svg_conform behavior to svgcheck

Instance Method Summary collapse

Constructor Details

#initializeCompatibilityEngine

Returns a new instance of CompatibilityEngine.



8
9
10
# File 'lib/svg_conform/external_checkers/svgcheck/compatibility_engine.rb', line 8

def initialize
  # Load any compatibility-specific configuration
end

Instance Method Details

#filter_errors_for_svgcheck(errors, _filename, _validation_result) ⇒ Object

Filter errors for svgcheck compatibility



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/svg_conform/external_checkers/svgcheck/compatibility_engine.rb', line 30

def filter_errors_for_svgcheck(errors, _filename, _validation_result)
  filtered_errors = []

  errors.each do |error|
    # Skip namespace_validation errors only for RDF/metadata namespaces
    # svgcheck skips these silently, but reports other namespace errors
    # Only skip RDF-related namespace errors
    if (error.requirement_id == "namespace_validation") && rdf_namespace_error?(error)
      next
    end

    # Map svg_conform requirement IDs to svgcheck-compatible ones
    mapped_req_id = map_requirement_id(error.requirement_id)
    next if mapped_req_id.nil? # Skip unmapped requirements

    filtered_errors << [error, mapped_req_id]
  end

  filtered_errors
end

#should_include_validity_errors?(validation_result, filename) ⇒ Boolean

Check if validity errors should be included as regular errors (for svgcheck compatibility)

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/svg_conform/external_checkers/svgcheck/compatibility_engine.rb', line 20

def should_include_validity_errors?(validation_result, filename)
  # Include validity errors if both width and height are present
  # This matches svgcheck's behavior from the mapping config
  return false unless validation_result.validity_errors.any?

  # Check for specific datatype condition mentioned in mapping config
  has_width_and_height_datatype_condition?(validation_result, filename)
end

#should_mimic_parse_failure?(_filename, _validation_result) ⇒ Boolean

Check if file should be treated as unparseable by svgcheck

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/svg_conform/external_checkers/svgcheck/compatibility_engine.rb', line 13

def should_mimic_parse_failure?(_filename, _validation_result)
  # Implement parse failure detection logic based on svgcheck behavior
  # For now, return false - this would need to be enhanced based on actual svgcheck behavior
  false
end