Module: Trailblazer::Circuit::Trace::Present
- Defined in:
- lib/trailblazer/circuit/present.rb
Overview
TODO:
-
Struct for debug_item
Class Method Summary collapse
- .color_map ⇒ Object
- .color_table ⇒ Object
- .colorify(string, color) ⇒ Object
- .to_name(debug_item) ⇒ Object
- .to_options(debug_item) ⇒ Object
- .tree(stack, level = 1, tree = []) ⇒ Object
- .tree_for(stack, level, tree) ⇒ Object
Class Method Details
.color_map ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/trailblazer/circuit/present.rb', line 52 def color_map { Trailblazer::Circuit::Start => :blue, Trailblazer::Circuit::End => :pink, Trailblazer::Circuit::Right => :green, Trailblazer::Circuit::Left => :red } end |
.color_table ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/trailblazer/circuit/present.rb', line 61 def color_table { red: 31, green: 32, yellow: 33, blue: 34, pink: 35 } end |
.colorify(string, color) ⇒ Object
48 49 50 |
# File 'lib/trailblazer/circuit/present.rb', line 48 def colorify(string, color) "\e[#{color_table[color]}m#{string}\e[0m" end |
.to_name(debug_item) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/trailblazer/circuit/present.rb', line 33 def to_name(debug_item) track = debug_item[2] klass = track.class == Class ? track : track.class color = color_map[klass] return debug_item[0].to_s unless color colorify(debug_item[0], color) end |
.to_options(debug_item) ⇒ Object
42 43 44 |
# File 'lib/trailblazer/circuit/present.rb', line 42 def (debug_item) debug_item[4] end |
.tree(stack, level = 1, tree = []) ⇒ Object
11 12 13 14 15 |
# File 'lib/trailblazer/circuit/present.rb', line 11 def tree(stack, level=1, tree=[]) tree_for(stack, level, tree) Hirb::Console.format_output(tree, class: :tree, type: :directory) end |
.tree_for(stack, level, tree) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/trailblazer/circuit/present.rb', line 17 def tree_for(stack, level, tree) stack.each do |debug_item| if debug_item.size == 2 # flat tree << [ level, debug_item[0].last[debug_item[0][0]] || debug_item[0][0] ] else # nesting tree << [ level, debug_item[0][0] ] tree_for(debug_item[1..-2], level + 1, tree) tree << [ level+1, debug_item[-1][0] ] end tree end end |