Module: Moult::SymbolId

Defined in:
lib/moult/symbol_id.rb

Overview

Builds the stable symbol id used as the cross-analysis join key: ":<start_line>:" (path relative to the analysis root, start_line 1-based). Shared by Scoring (hotspots) and Index (dead code) so the two analyses mint identical ids for the same definition and the Phase 3 coverage merge can join them. Centralised here so the format cannot drift between producers.

Class Method Summary collapse

Class Method Details

.for(path:, start_line:, fqname:) ⇒ String

Parameters:

  • path (String)

    path relative to the analysis root

  • start_line (Integer)

    1-based definition line

  • fqname (String)

    fully-qualified lexical name (Class#method / Class.method)

Returns:

  • (String)


19
20
21
# File 'lib/moult/symbol_id.rb', line 19

def for(path:, start_line:, fqname:)
  "#{path}:#{start_line}:#{fqname}"
end

.relative_path(abs, root) ⇒ String

Returns path relative to root.

Parameters:

  • abs (String)

    absolute path

  • root (String)

    absolute analysis root

Returns:

  • (String)

    path relative to root



26
27
28
# File 'lib/moult/symbol_id.rb', line 26

def relative_path(abs, root)
  Pathname.new(abs).relative_path_from(Pathname.new(root)).to_s
end