Class: RailsFlowMap::SequenceFormatter
- Inherits:
-
Object
- Object
- RailsFlowMap::SequenceFormatter
- Defined in:
- lib/rails_flow_map/formatters/sequence_formatter.rb
Overview
Generates sequence diagrams showing request flow through the application
This formatter creates Mermaid sequence diagrams that visualize how requests flow through controllers, services, models, and the database. It can optionally include middleware, callbacks, and validation steps.
Instance Method Summary collapse
-
#format(graph = @graph) ⇒ String
Generates the sequence diagram.
-
#initialize(graph, options = {}) ⇒ SequenceFormatter
constructor
Creates a new sequence diagram formatter.
Constructor Details
#initialize(graph, options = {}) ⇒ SequenceFormatter
Creates a new sequence diagram formatter
31 32 33 34 35 36 37 38 |
# File 'lib/rails_flow_map/formatters/sequence_formatter.rb', line 31 def initialize(graph, = {}) @graph = graph @endpoint = [:endpoint] @include_middleware = [:include_middleware] || false @include_callbacks = [:include_callbacks] || false @include_validations = [:include_validations] || false @include_database = [:include_database] || true end |
Instance Method Details
#format(graph = @graph) ⇒ String
Generates the sequence diagram
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rails_flow_map/formatters/sequence_formatter.rb', line 44 def format(graph = @graph) output = [] output << "```mermaid" output << "sequenceDiagram" output << " autonumber" # 参加者の定義 output.concat(define_participants(graph)) # エンドポイントに関連するノードを取得 route_nodes = filter_route_nodes(graph) if route_nodes.empty? output << " Note over Client: No routes found for endpoint: #{@endpoint}" else route_nodes.each do |route| output << "" output << " Note over Client: === #{route.attributes[:verb]} #{route.attributes[:path]} ===" output.concat(generate_sequence_for_route(route, graph)) end end output << "```" output.join("\n") end |