Class: Markdown::Merge::ConflictResolver

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

Overview

Resolves conflicts between matching Markdown elements from template and destination.

When two elements have the same signature but different content, the resolver
determines which version to use based on the configured preference.

Inherits from Ast::Merge::ConflictResolverBase using the :node strategy,
which resolves conflicts on a per-node-pair basis.

Examples:

Basic usage

resolver = ConflictResolver.new(
  preference: :destination,
  template_analysis: template_analysis,
  dest_analysis: dest_analysis
)
resolution = resolver.resolve(template_node, dest_node, template_index: 0, dest_index: 0)
case resolution[:source]
when :template
  # Use template version
when :destination
  # Use destination version
end

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(preference:, template_analysis:, dest_analysis:, **options) ⇒ ConflictResolver

Initialize a conflict resolver

Parameters:

  • preference (Symbol)

    Which version to prefer (:destination or :template)

  • template_analysis (FileAnalysisBase)

    Analysis of the template file

  • dest_analysis (FileAnalysisBase)

    Analysis of the destination file

  • options (Hash)

    Additional options for forward compatibility



36
37
38
39
40
41
42
43
44
# File 'lib/markdown/merge/conflict_resolver.rb', line 36

def initialize(preference:, template_analysis:, dest_analysis:, **options)
  super(
    strategy: :node,
    preference: preference,
    template_analysis: template_analysis,
    dest_analysis: dest_analysis,
    **options
  )
end