Module: Deprewriter::Rewriter

Defined in:
lib/deprewriter/rewriter.rb

Overview

Handles source code rewriting for deprecated methods

Class Method Summary collapse

Class Method Details

.transform_source(source, method_name, line, to:, from: nil) ⇒ String

Returns The rewritten source code.

Parameters:

  • source (String)

    The source code

  • method_name (Symbol)

    The name of the method to rewrite

  • line (Integer)

    Line number where the method is called

  • from (String, nil) (defaults to: nil)

    Pattern to match for transformation

  • to (String)

    Pattern to transform to

Returns:

  • (String)

    The rewritten source code



14
15
16
17
# File 'lib/deprewriter/rewriter.rb', line 14

def transform_source(source, method_name, line, to:, from: nil)
  node = CallSiteFinder.new(method_name, line, from: from).find(source)
  Transformer.new(source, node, to).transform
end