Sha256: 6ffd4c2b41e34bf0cda2e9af0f490dd36618e1b0ba69485f0d78a5d909af37a9

Contents?: true

Size: 894 Bytes

Versions: 3

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

module ActionDispatch
  module Journey # :nodoc:
    module NFA # :nodoc:
      module Dot # :nodoc:
        def to_dot
          edges = transitions.map { |from, sym, to|
            "  #{from} -> #{to} [label=\"#{sym || 'ε'}\"];"
          }

          #memo_nodes = memos.values.flatten.map { |n|
          #  label = n
          #  if Journey::Route === n
          #    label = "#{n.verb.source} #{n.path.spec}"
          #  end
          #  "  #{n.object_id} [label=\"#{label}\", shape=box];"
          #}
          #memo_edges = memos.flat_map { |k, memos|
          #  (memos || []).map { |v| "  #{k} -> #{v.object_id};" }
          #}.uniq

          <<-eodot
digraph nfa {
  rankdir=LR;
  node [shape = doublecircle];
  #{accepting_states.join ' '};
  node [shape = circle];
#{edges.join "\n"}
}
          eodot
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
actionpack-5.2.0.beta2 lib/action_dispatch/journey/nfa/dot.rb
actionpack-5.2.0.beta1 lib/action_dispatch/journey/nfa/dot.rb
ruby-on-quails-0.1.0 actionpack/lib/action_dispatch/journey/nfa/dot.rb