Class: Markdown::Merge::FileAligner

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

Overview

Aligns Markdown block elements between template and destination files.

Uses structural signatures to match headings, paragraphs, lists, code blocks, and other block elements. The alignment is then used by SmartMerger to determine how to combine the files.

Examples:

Basic usage

aligner = FileAligner.new(template_analysis, dest_analysis)
alignment = aligner.align
alignment.each do |entry|
  case entry[:type]
  when :match
    # Both files have this element
  when :template_only
    # Only in template
  when :dest_only
    # Only in destination
  end
end

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_analysis, dest_analysis, match_refiner: nil, **options) ⇒ FileAligner

Initialize a file aligner

Parameters:

  • template_analysis (FileAnalysisBase)

    Analysis of the template file

  • dest_analysis (FileAnalysisBase)

    Analysis of the destination file

  • match_refiner (#call, nil) (defaults to: nil)

    Optional match refiner for fuzzy matching



42
43
44
# File 'lib/markdown/merge/file_aligner.rb', line 42

def initialize(template_analysis, dest_analysis, match_refiner: nil, **options)
  super(template_analysis, dest_analysis, match_refiner: match_refiner, **options)
end

Instance Attribute Details

#dest_analysisFileAnalysisBase (readonly)

Returns Destination file analysis.

Returns:



32
33
34
# File 'lib/markdown/merge/file_aligner.rb', line 32

def dest_analysis
  @dest_analysis
end

#match_refiner#call? (readonly)

Returns Optional match refiner for fuzzy matching.

Returns:

  • (#call, nil)

    Optional match refiner for fuzzy matching



35
36
37
# File 'lib/markdown/merge/file_aligner.rb', line 35

def match_refiner
  @match_refiner
end

#template_analysisFileAnalysisBase (readonly)

Returns Template file analysis.

Returns:



29
30
31
# File 'lib/markdown/merge/file_aligner.rb', line 29

def template_analysis
  @template_analysis
end