Module: Trailblazer::Developer::Render::Linear
- Defined in:
- lib/trailblazer/developer/render/linear.rb
Constant Summary collapse
- Operator =
{fail: "<<", pass: ">>", step: ">"}
Class Method Summary collapse
- .call(operation, style: :line) ⇒ Object
- .inspect_func(step) ⇒ Object
- .inspect_line(names) ⇒ Object
- .inspect_rows(names) ⇒ Object
Class Method Details
.call(operation, style: :line) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trailblazer/developer/render/linear.rb', line 17 def call(operation, style: :line) graph = Introspect::Graph(operation) rows = graph.collect do |node, i| next if node[:data][:stop_event] # DISCUSS: show this? created_by = node[:data][:dsl_track] || :pass [i, [created_by, node.id]] end.compact rows = rows[1..-1] # remove start return inspect_line(rows) if style == :line return inspect_rows(rows) end |
.inspect_func(step) ⇒ Object
35 36 37 |
# File 'lib/trailblazer/developer/render/linear.rb', line 35 def inspect_func(step) @inspect[step] end |
.inspect_line(names) ⇒ Object
41 42 43 44 |
# File 'lib/trailblazer/developer/render/linear.rb', line 41 def inspect_line(names) string = names.collect { |i, (end_of_edge, name)| "#{Operator[end_of_edge]}#{name}" }.join(",") "[#{string}]" end |
.inspect_rows(names) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/trailblazer/developer/render/linear.rb', line 46 def inspect_rows(names) string = names.collect do |i, (end_of_edge, name)| operator = Operator[end_of_edge] op = "#{operator}#{name}" padding = 38 proc = if operator == "<<" sprintf("%- #{padding}s", op) elsif [">", ">>", "&"].include?(operator.to_s) sprintf("% #{padding}s", op) else pad = " " * ((padding - op.length) / 2) "#{pad}#{op}#{pad}" end proc = proc.gsub(" ", "=") sprintf("%2d %s", i, proc) end.join("\n") "\n#{string}" end |