Module: Trailblazer::Developer::Wtf::Renderer
- Defined in:
- lib/trailblazer/developer/wtf/renderer.rb
Defined Under Namespace
Modules: String
Constant Summary collapse
- DEFAULT_COLOR_MAP =
{ pass: :green, fail: :brown }
- SIGNALS_MAP =
{ :'Trailblazer::Activity::Right' => :pass, :'Trailblazer::Activity::FastTrack::PassFast' => :pass, :'Trailblazer::Activity::Left' => :fail, :'Trailblazer::Activity::FastTrack::FailFast' => :fail, }
Class Method Summary collapse
- .apply_style(label, debugger_node, style:) ⇒ Object
-
.call(debugger_trace:, debugger_node:, style: {}, **options) ⇒ Object
options can be {#<Debugger::Node> => [:red, :bold]}.
- .fmt(line, style) ⇒ Object
- .signal_of(debugger_node) ⇒ Object
- .styled_label(debugger_trace, debugger_node, color_map:, **options) ⇒ Object
Class Method Details
.apply_style(label, debugger_node, style:) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 30 def apply_style(label, debugger_node, style:, **) return label unless styles = style[debugger_node.trace_node] styles.each { |s| label = fmt(label, s) } label end |
.call(debugger_trace:, debugger_node:, style: {}, **options) ⇒ Object
options can be {#<Debugger::Node> => [:red, :bold]}
18 19 20 21 22 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 18 def call(debugger_trace:, debugger_node:, style: {}, **) label = styled_label(debugger_trace, debugger_node, style: style, **) [debugger_node.level, label] end |
.fmt(line, style) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 37 def fmt(line, style) if line.is_a? Method line = "#<Method: #<Class:>.#{line.name}>" end return line unless style String.send(style, line) end |
.signal_of(debugger_node) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 45 def signal_of(debugger_node) entity_signal = debugger_node.incomplete? ? nil : debugger_node.snapshot_after.data[:signal] entity_klass = entity_signal.is_a?(Class) ? entity_signal : entity_signal.class SIGNALS_MAP[entity_klass.name.to_sym] end |
.styled_label(debugger_trace, debugger_node, color_map:, **options) ⇒ Object
24 25 26 27 28 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 24 def styled_label(debugger_trace, debugger_node, color_map:, **) label = apply_style(debugger_node.label, debugger_node, **) %{#{fmt(label, color_map[signal_of(debugger_node)])}} end |