Class: BlastRadius::Formatters::MermaidFormatter

Inherits:
Base
  • Object
show all
Defined in:
lib/blast_radius/formatters/mermaid_formatter.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BlastRadius::Formatters::Base

Instance Method Details

#format(root_node) ⇒ String

Format dependency tree as Mermaid diagram

Parameters:

  • root_node (Node)

    root node of dependency tree

Returns:

  • (String)

    Mermaid diagram syntax



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/blast_radius/formatters/mermaid_formatter.rb', line 9

def format(root_node)
  @node_counter = 0
  @node_ids = {}
  lines = ['graph TD']

  # Assign ID to root node
  node_id(root_node)

  # Process all nodes
  format_node(root_node, lines)

  lines.join("\n")
end