Class: RailsErd::PlantUml

Inherits:
RailsERD::Diagram
  • Object
show all
Defined in:
lib/rails/plant_uml.rb

Overview

PlantUML implementation of the Diagram class, which will output a .puml file that can be processed by the PlantUML renderer.

Instance Method Summary collapse

Constructor Details

#initialize(domain, options = {}) ⇒ PlantUml

Initialize the diagram



19
20
21
22
23
24
25
26
27
28
# File 'lib/rails/plant_uml.rb', line 19

def initialize(domain, options = {})
  @domain = domain
  @title = options[:title] || "Entity Relationship Diagram"
  @app_name = options[:app_name] || "SOFware"
  @filename = options[:filename] || "erd.puml"
  @filename += ".puml" unless @filename.end_with?(".puml")
  @only = options[:only]
  @timestamp = Time.current.iso8601
  @markup = []
end

Instance Method Details

#saveObject

Main method to generate the PlantUML diagram



31
32
33
34
35
36
37
38
39
40
# File 'lib/rails/plant_uml.rb', line 31

def save
  # Generate the PlantUML content
  generate_diagram

  # Write to file
  File.write(@filename, @markup.join("\n"))

  # Return the filename so it can be used in the CLI output
  @filename
end