Module: Kettle::Dev::SourceMerger

Defined in:
sig/kettle/dev.rbs

Overview

Prism-based AST merging for templated Ruby files. Handles strategy dispatch (skip/replace/append/merge).

Uses prism-merge for AST-aware merging with support for:

  • Freeze blocks (kettle-dev:freeze / kettle-dev:unfreeze)
  • Comment preservation
  • Signature-based node matching

Constant Summary collapse

BUG_URL =

Returns:

  • (String)

Class Method Summary collapse

Class Method Details

.applyString

Apply a templating strategy to merge source and destination Ruby files

Parameters:

  • strategy (Symbol)

    Merge strategy - :skip, :replace, :append, or :merge

  • src (String)

    Template source content

  • dest (String)

    Destination file content

  • path (String)

    File path (for error messages)

Returns:

  • (String)

    Merged content with comments preserved

Raises:



423
# File 'sig/kettle/dev.rbs', line 423

def self.apply: (

.apply_appendString

Apply append strategy using prism-merge

Parameters:

  • src_content (String)

    Template source content

  • dest_content (String)

    Destination content

Returns:

  • (String)

    Merged content with destination preference



454
# File 'sig/kettle/dev.rbs', line 454

def self.apply_append: (String src_content, String dest_content) -> String

.apply_mergeString

Apply merge strategy using prism-merge

Parameters:

  • src_content (String)

    Template source content

  • dest_content (String)

    Destination content

Returns:

  • (String)

    Merged content with template preference



461
# File 'sig/kettle/dev.rbs', line 461

def self.apply_merge: (String src_content, String dest_content) -> String

.create_signature_generatorProc

Create a signature generator for prism-merge Handles various Ruby node types for proper matching during merge operations

Returns:

  • (Proc)

    Signature generator lambda



467
# File 'sig/kettle/dev.rbs', line 467

def self.create_signature_generator: () -> ^(Prism::Node) -> (Array[untyped] | Prism::Node)

.ensure_trailing_newlineString

Ensure text ends with newline

Parameters:

  • text (String, nil)

    Text to process

Returns:

  • (String)

    Text with trailing newline



447
# File 'sig/kettle/dev.rbs', line 447

def self.ensure_trailing_newline: (String? text) -> String

.normalize_strategySymbol

Normalize strategy symbol

Parameters:

  • strategy (Symbol, nil)

    Strategy to normalize

Returns:

  • (Symbol)

    Normalized strategy (:skip if nil)



434
# File 'sig/kettle/dev.rbs', line 434

def self.normalize_strategy: (Symbol? strategy) -> Symbol

.warn_bugvoid

This method returns an undefined value.

Warn about bugs and print error information

Parameters:

  • path (String)

    File path that caused the error

  • error (StandardError)

    The error that occurred



441
# File 'sig/kettle/dev.rbs', line 441

def self.warn_bug: (String path, StandardError error) -> void