Class: Dbwatcher::Services::MermaidSyntax::ErdBuilder
- Inherits:
-
BaseBuilder
- Object
- BaseBuilder
- Dbwatcher::Services::MermaidSyntax::ErdBuilder
- Defined in:
- lib/dbwatcher/services/mermaid_syntax/erd_builder.rb
Overview
Builder for Entity Relationship Diagrams in Mermaid syntax
Generates Mermaid ERD syntax from a standardized dataset with support for attributes and relationships with cardinality.
Instance Method Summary collapse
-
#build_empty(message) ⇒ String
Build empty ERD with message.
-
#build_from_dataset(dataset) ⇒ String
Build ERD content from dataset.
Methods inherited from BaseBuilder
Methods included from Logging
#debug_enabled?, #log_debug, #log_error, #log_info, #log_warn
Constructor Details
This class inherits a constructor from Dbwatcher::Services::MermaidSyntax::BaseBuilder
Instance Method Details
#build_empty(message) ⇒ String
Build empty ERD with message
43 44 45 46 47 48 49 50 51 |
# File 'lib/dbwatcher/services/mermaid_syntax/erd_builder.rb', line 43 def build_empty() = sanitize_text() [ "erDiagram", " EMPTY_STATE {", " string message \"#{}\"", " }" ].join("\n") end |
#build_from_dataset(dataset) ⇒ String
Build ERD content from dataset
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dbwatcher/services/mermaid_syntax/erd_builder.rb', line 20 def build_from_dataset(dataset) lines = ["erDiagram"] # Add entity definitions with attributes dataset.entities.each_value do |entity| lines += build_erd_entity(entity) end # Add relationships unless dataset.relationships.empty? lines << "" dataset.relationships.each do |relationship| lines << build_erd_relationship(relationship, dataset) end end lines.join("\n") end |