Class: Lutaml::Cli::TreeViewFormatter
- Inherits:
-
Object
- Object
- Lutaml::Cli::TreeViewFormatter
- Defined in:
- lib/lutaml/cli/tree_view_formatter.rb
Overview
TreeViewFormatter formats UML repository contents as a colored tree
Constant Summary collapse
- COLORS =
Color scheme for different element types
{ package: :cyan, class: :green, interface: :magenta, enumeration: :yellow, attribute: "#FFD700", # Light Yellow/Gold operation: "#87CEEB", # Light Blue/Sky Blue association: :white, diagram: "#DDA0DD", # Light Magenta/Plum statistics: "#ADD8E6", # Light Cyan }.freeze
- ICONS =
Icons for different element types
{ package: "📦", class: "📦", interface: "🔌", enumeration: "🔢", attribute: "🔹", operation: "🔧", association: "🔗", diagram: "📊", }.freeze
- TREE_CHARS =
Tree drawing characters
{ vertical: "│", branch: "├──", last_branch: "└──", space: " ", continuation: "│ ", }.freeze
Instance Method Summary collapse
-
#format(repository) ⇒ String
Format the entire repository as a tree.
-
#initialize(options = {}) ⇒ TreeViewFormatter
constructor
A new instance of TreeViewFormatter.
Constructor Details
#initialize(options = {}) ⇒ TreeViewFormatter
Returns a new instance of TreeViewFormatter.
43 44 45 46 47 48 49 50 |
# File 'lib/lutaml/cli/tree_view_formatter.rb', line 43 def initialize( = {}) @max_depth = [:max_depth] @show_attributes = .fetch(:show_attributes, true) @show_operations = .fetch(:show_operations, true) @show_associations = .fetch(:show_associations, false) @no_color = .fetch(:no_color, false) @current_depth = 0 end |
Instance Method Details
#format(repository) ⇒ String
Format the entire repository as a tree
The repository to format
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/lutaml/cli/tree_view_formatter.rb', line 57 def format(repository) # rubocop:disable Metrics/MethodLength output = [] # Start with ModelRoot output << colorize("ModelRoot", :package) # Get all top-level packages root_packages = repository.list_packages("ModelRoot", recursive: false) root_packages.each_with_index do |pkg, idx| is_last = idx == root_packages.size - 1 output << format_package(pkg, repository, 0, is_last, "") end # Add statistics at the end output << "" output << format_statistics(repository.statistics) output.join("\n") end |