Class: Canon::Comparison::MatchOptions::XmlResolver
- Inherits:
-
BaseResolver
- Object
- BaseResolver
- Canon::Comparison::MatchOptions::XmlResolver
- Defined in:
- lib/canon/comparison/match_options/xml_resolver.rb
Overview
XML/HTML-specific match options resolver
Constant Summary collapse
- FORMAT_DEFAULTS =
Format-specific defaults for XML/HTML
Sensitive elements (preserve structural whitespace):
-
XML: none by default — all structural whitespace stripped
-
HTML: pre, code, textarea, script, style by default
Use preserve_whitespace_elements option to add elements that preserve whitespace.
-
{ html: { preprocessing: :rendered, text_content: :normalize, structural_whitespace: :normalize, attribute_presence: :strict, attribute_order: :ignore, attribute_values: :strict, element_position: :ignore, comments: :ignore, whitespace_type: :strict, }, xml: { preprocessing: :none, text_content: :strict, structural_whitespace: :strict, attribute_presence: :strict, attribute_order: :ignore, attribute_values: :strict, element_position: :strict, comments: :strict, whitespace_type: :strict, }, }.freeze
- MATCH_PROFILES =
Predefined match profiles for XML/HTML
{ strict: { preprocessing: :none, text_content: :strict, structural_whitespace: :strict, attribute_presence: :strict, attribute_order: :strict, attribute_values: :strict, element_position: :strict, comments: :strict, whitespace_type: :strict, }, rendered: { preprocessing: :none, text_content: :normalize, structural_whitespace: :normalize, attribute_presence: :strict, attribute_order: :strict, attribute_values: :strict, element_position: :strict, comments: :ignore, whitespace_type: :strict, }, html4: { preprocessing: :rendered, text_content: :normalize, structural_whitespace: :normalize, attribute_presence: :strict, attribute_order: :strict, attribute_values: :normalize, element_position: :ignore, comments: :ignore, whitespace_type: :strict, }, html5: { preprocessing: :rendered, text_content: :normalize, structural_whitespace: :normalize, attribute_presence: :strict, attribute_order: :strict, attribute_values: :strict, element_position: :ignore, comments: :ignore, whitespace_type: :strict, }, spec_friendly: { preprocessing: :rendered, text_content: :normalize, structural_whitespace: :ignore, attribute_presence: :strict, attribute_order: :ignore, attribute_values: :normalize, element_position: :ignore, comments: :ignore, whitespace_type: :strict, }, content_only: { preprocessing: :c14n, text_content: :normalize, structural_whitespace: :ignore, attribute_presence: :strict, attribute_order: :ignore, attribute_values: :normalize, element_position: :ignore, comments: :ignore, whitespace_type: :strict, }, }.freeze
Class Method Summary collapse
-
.format_defaults(format) ⇒ Object
Get format-specific default options.
-
.get_profile_options(profile) ⇒ Object
Get options for a named profile.
Methods inherited from BaseResolver
Class Method Details
.format_defaults(format) ⇒ Object
Get format-specific default options
117 118 119 |
# File 'lib/canon/comparison/match_options/xml_resolver.rb', line 117 def format_defaults(format) FORMAT_DEFAULTS[format]&.dup || FORMAT_DEFAULTS[:xml].dup end |
.get_profile_options(profile) ⇒ Object
Get options for a named profile
122 123 124 125 126 127 128 129 |
# File 'lib/canon/comparison/match_options/xml_resolver.rb', line 122 def (profile) unless MATCH_PROFILES.key?(profile) raise Canon::Error, "Unknown match profile: #{profile}. " \ "Valid profiles: #{MATCH_PROFILES.keys.join(', ')}" end MATCH_PROFILES[profile].dup end |