Module: ArchUnit::Slices::Uml::PlantUmlRenderer
- Defined in:
- lib/archunit/slices/uml/export_diagram.rb
Overview
Stable PlantUML generation and UTF-8 file export for projected slice graphs.
Class Method Summary collapse
Class Method Details
.export(edges, output_path, components: []) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/archunit/slices/uml/export_diagram.rb', line 26 def export(edges, output_path, components: []) path = normalized_path(output_path) FileUtils.mkdir_p(File.dirname(path)) unless File.dirname(path) == '.' File.binwrite(path, render(edges, components:).encode(Encoding::UTF_8)) nil end |
.render(edges, components: []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/archunit/slices/uml/export_diagram.rb', line 14 def render(edges, components: []) validate_edges(edges) components = component_names(edges, components) lines = ['@startuml'] lines.concat(components.map { |name| " component [#{plant_uml_name(name)}]" }) lines.concat(sorted_edges(edges).map do |edge| " [#{plant_uml_name(edge.source_label)}] --> " \ "[#{plant_uml_name(edge.target_label)}]" end) "#{lines.append('@enduml').join("\n")}\n" end |