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
-
.call(tree:, task_node:, position:) ⇒ Object
tree: Array of Trace::TreeNodes::Node task_node - current Trace::TreeNodes::Node to render position - task_node’s position in tree.
- .fmt(line, style) ⇒ Object
- .signal_of(task_node) ⇒ Object
- .value_for(tree, task_node, position) ⇒ Object
Class Method Details
.call(tree:, task_node:, position:) ⇒ Object
tree: Array of Trace::TreeNodes::Node task_node - current Trace::TreeNodes::Node to render position - task_node’s position in tree
21 22 23 24 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 21 def call(tree:, task_node:, position:) value = value_for(tree, task_node, position) [task_node.level, value] end |
.fmt(line, style) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 38 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(task_node) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 46 def signal_of(task_node) entity_signal = task_node.output.data[:signal] entity_klass = entity_signal.is_a?(Class) ? entity_signal : entity_signal.class SIGNALS_MAP[entity_klass.name.to_sym] end |
.value_for(tree, task_node, position) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/trailblazer/developer/wtf/renderer.rb', line 26 def value_for(tree, task_node, position) if task_node.output.nil? && tree[position.next].nil? # i.e. when exception raised return %{#{fmt(fmt(task_node.value, :red), :bold)}} end if task_node.output.nil? # i.e. on entry/exit point of activity return %{#{task_node.value}} end %{#{fmt(task_node.value, task_node.color_map[ signal_of(task_node) ])}} end |