Class: Lutaml::Xsd::PackageTreeFormatter
- Inherits:
-
Object
- Object
- Lutaml::Xsd::PackageTreeFormatter
- Defined in:
- lib/lutaml/xsd/package_tree_formatter.rb
Overview
Formats LXR package contents as a colorized tree structure
Responsibilities:
-
Extract and organize package file listing
-
Generate colorized tree output with appropriate icons
-
Handle different output formats (tree, flat)
-
Calculate and display file sizes
Constant Summary collapse
- COLORS =
Color scheme for different file types
{ directory: %i[cyan bold], xsd_file: :green, metadata_file: :yellow, serialized_file: :blue, index_file: :magenta, file_size: :black, summary_label: [:bold], summary_value: %i[cyan bold], }.freeze
- ICONS =
Icons for different file types
{ directory: "📁", metadata: "📋", xsd: "📄", index: "🔍", mapping: "🔖", relation: "🔗", }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#package_path ⇒ Object
readonly
Returns the value of attribute package_path.
Instance Method Summary collapse
-
#format ⇒ String
Format package contents as tree.
-
#initialize(package_path, options = {}) ⇒ PackageTreeFormatter
constructor
Initialize formatter.
Constructor Details
#initialize(package_path, options = {}) ⇒ PackageTreeFormatter
Initialize formatter
59 60 61 62 63 64 65 66 |
# File 'lib/lutaml/xsd/package_tree_formatter.rb', line 59 def initialize(package_path, = {}) @package_path = package_path @options = { show_sizes: false, no_color: false, format: :tree, }.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
50 51 52 |
# File 'lib/lutaml/xsd/package_tree_formatter.rb', line 50 def @options end |
#package_path ⇒ Object (readonly)
Returns the value of attribute package_path.
50 51 52 |
# File 'lib/lutaml/xsd/package_tree_formatter.rb', line 50 def package_path @package_path end |
Instance Method Details
#format ⇒ String
Format package contents as tree
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/lutaml/xsd/package_tree_formatter.rb', line 71 def format entries = extract_entries stats = calculate_statistics(entries) output = [] output << format_header(stats[:total_size]) output << format_entries(entries) if [:format] == :tree output << format_flat_list(entries) if [:format] == :flat output << "" output << format_summary(stats) output.join("\n") end |