Class: Psych::Merge::ConflictResolver

Inherits:
Ast::Merge::ConflictResolverBase
  • Object
show all
Defined in:
lib/psych/merge/conflict_resolver.rb

Overview

Resolves conflicts between template and destination YAML content
using structural signatures and configurable preferences.

Inherits from Ast::Merge::ConflictResolverBase using the :batch strategy,
which resolves all conflicts at once using signature maps.

Examples:

Basic usage

resolver = ConflictResolver.new(template_analysis, dest_analysis)
resolver.resolve(result)

With recursive merge for nested structures

resolver = ConflictResolver.new(
  template_analysis,
  dest_analysis,
  recursive: true,
  add_template_only_nodes: true
)

See Also:

  • Ast::Merge::ConflictResolverBase

Instance Method Summary collapse

Constructor Details

#initialize(template_analysis, dest_analysis, preference: :destination, add_template_only_nodes: false, remove_template_missing_nodes: false, recursive: true, match_refiner: nil, node_typing: nil, **options) ⇒ ConflictResolver

Creates a new ConflictResolver

Parameters:

  • template_analysis (FileAnalysis)

    Analyzed template file

  • dest_analysis (FileAnalysis)

    Analyzed destination file

  • preference (Symbol, Hash) (defaults to: :destination)

    Which version to prefer when
    nodes have matching signatures:

    • :destination (default) - Keep destination version (customizations)
    • :template - Use template version (updates)
  • add_template_only_nodes (Boolean) (defaults to: false)

    Whether to add nodes only in template

  • remove_template_missing_nodes (Boolean) (defaults to: false)

    Whether to remove destination nodes not in template

  • recursive (Boolean, Integer) (defaults to: true)

    Whether to merge nested structures recursively

    • true: unlimited depth (default)
    • false: disabled
    • Integer > 0: max depth
  • match_refiner (#call, nil) (defaults to: nil)

    Optional match refiner for fuzzy matching

  • options (Hash)

    Additional options for forward compatibility

  • node_typing (Hash{Symbol,String => #call}, nil) (defaults to: nil)

    Node typing configuration
    for per-node-type preferences



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/psych/merge/conflict_resolver.rb', line 43

def initialize(template_analysis, dest_analysis, preference: :destination, add_template_only_nodes: false, remove_template_missing_nodes: false, recursive: true, match_refiner: nil, node_typing: nil, **options)
  super(
    strategy: :batch,
    preference: preference,
    template_analysis: template_analysis,
    dest_analysis: dest_analysis,
    add_template_only_nodes: add_template_only_nodes,
    remove_template_missing_nodes: remove_template_missing_nodes,
    recursive: recursive,
    match_refiner: match_refiner,
    **options
  )
  @node_typing = node_typing
  @emitter = Emitter.new
end