Class: TypedOperation::Instrumentation::TreeFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/typed_operation/instrumentation/tree_formatter.rb

Overview

Formats execution traces as a visual chain for console output. Shows operation flow with arrows and pass mode indicators.

Constant Summary collapse

ARROW =

: String

""
FALLBACK_ARROW =

: String

""
SUCCESS_MARK =

: String

""
FAILURE_MARK =

: String

""
SKIPPED_MARK =

: String

""
PASS_MODES =
{
  kwargs_splat: "**ctx",
  single_value: "ctx",
  transform: "transform",
  fallback: "fallback"
}.freeze
COLORS =

: Hash[Symbol, String]

{
  green: "\e[32m",
  red: "\e[31m",
  yellow: "\e[33m",
  cyan: "\e[36m",
  dim: "\e[2m",
  bold: "\e[1m",
  reset: "\e[0m"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(color: nil) ⇒ TreeFormatter

: (?color: bool?) -> void



36
37
38
# File 'lib/typed_operation/instrumentation/tree_formatter.rb', line 36

def initialize(color: nil)
  @color = color.nil? ? detect_color_support : color
end

Instance Method Details

#format(trace) ⇒ Object

: (Trace) -> String



41
42
43
44
45
# File 'lib/typed_operation/instrumentation/tree_formatter.rb', line 41

def format(trace)
  lines = [] #: Array[String]
  format_chain(trace, lines)
  lines.join("\n")
end