Class: Canon::Comparison::MatchOptions::YamlResolver

Inherits:
BaseResolver
  • Object
show all
Defined in:
lib/canon/comparison/match_options/yaml_resolver.rb

Overview

YAML-specific match options resolver

Constant Summary collapse

FORMAT_DEFAULTS =

Format defaults for YAML

{
  yaml: {
    preprocessing: :none,
    text_content: :strict,
    structural_whitespace: :ignore,
    key_order: :ignore,
    comments: :ignore,
  },
}.freeze
MATCH_PROFILES =

Predefined match profiles for YAML

{
  strict: {
    preprocessing: :none,
    text_content: :strict,
    structural_whitespace: :strict,
    key_order: :strict,
    comments: :strict,
  },

  spec_friendly: {
    preprocessing: :normalize,
    text_content: :strict,
    structural_whitespace: :ignore,
    key_order: :ignore,
    comments: :ignore,
  },

  content_only: {
    preprocessing: :normalize,
    text_content: :normalize,
    structural_whitespace: :ignore,
    key_order: :ignore,
    comments: :ignore,
  },
}.freeze

Class Method Summary collapse

Methods inherited from BaseResolver

match_dimensions, resolve

Class Method Details

.format_defaults(format) ⇒ Object

Get format-specific default options



48
49
50
# File 'lib/canon/comparison/match_options/yaml_resolver.rb', line 48

def format_defaults(format)
  FORMAT_DEFAULTS[format]&.dup || FORMAT_DEFAULTS[:yaml].dup
end

.get_profile_options(profile) ⇒ Object

Get options for a named profile



53
54
55
56
57
58
59
60
# File 'lib/canon/comparison/match_options/yaml_resolver.rb', line 53

def get_profile_options(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