Class: SvgConform::Remediations::ColorRemediation

Inherits:
BaseRemediation
  • Object
show all
Defined in:
lib/svg_conform/remediations/color_remediation.rb

Overview

Remediation action for color-related issues that matches svgcheck behavior

Constant Summary collapse

DEFAULT_COLOR_THRESHOLD =

Default threshold if not specified in requirement

764
COLOR_DEFAULT =
"black"
COLOR_MAP =
{
  "rgb(0,0,0)" => "black",
}.freeze

Instance Method Summary collapse

Methods inherited from BaseRemediation

#execute, #should_execute?, #to_s

Instance Method Details

#apply(document, context) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/svg_conform/remediations/color_remediation.rb', line 18

def apply(document, context)
  # Store the context for use in other methods
  @context = context
  @failed_requirements = context[:failed_requirements] if context.is_a?(Hash)

  changes = []

  # Find all elements with color attributes
  document.traverse do |node|
    next unless node.respond_to?(:name) && node.name

    changes.concat(fix_color_attributes(node))
    changes.concat(fix_style_colors(node))
  end

  changes
end