Class: Lutaml::Cli::ResourceRegistry
- Inherits:
-
Object
- Object
- Lutaml::Cli::ResourceRegistry
- Defined in:
- lib/lutaml/cli/resource_registry.rb
Overview
ResourceRegistry manages element type configurations for CLI commands
This registry provides a centralized definition of UML element types and their corresponding repository methods and presenters. It enables extensibility by allowing new element types to be easily added.
Constant Summary collapse
- TYPES =
Element type configurations
Each type defines:
-
list_method: Repository method to list all elements of this type
-
find_method: Repository method to find a single element
-
presenter: Presenter class name for formatting output
-
icon: Display icon for this element type
-
description: Human-readable description
-
{ package: { list_method: :list_packages, find_method: :find_package, presenter: :PackagePresenter, icon: "📦", description: "Package container", }, class: { list_method: :all_classes, find_method: :find_class, presenter: :ClassPresenter, icon: "📋", description: "UML Class", }, diagram: { list_method: :all_diagrams, find_method: :find_diagram, presenter: :DiagramPresenter, icon: "🖼️", description: "UML Diagram", }, attribute: { list_method: :all_attributes, find_method: :find_attribute, presenter: :AttributePresenter, icon: "🔹", description: "Class attribute", }, association: { list_method: :all_associations, find_method: :find_association, presenter: :AssociationPresenter, icon: "🔗", description: "Class association", }, enum: { list_method: :all_enums, find_method: :find_enum, presenter: :EnumPresenter, icon: "🔢", description: "Enumeration", }, datatype: { list_method: :all_data_types, find_method: :find_data_type, presenter: :DataTypePresenter, icon: "📊", description: "Data type", }, }.freeze
Class Method Summary collapse
-
.config_for(type) ⇒ Hash?
Get configuration for a specific type.
-
.description_for(type) ⇒ String
Get description for a type.
-
.icon_for(type) ⇒ String
Get icon for a type.
-
.type_descriptions ⇒ Hash<Symbol, String>
Get all types with their descriptions.
-
.type_registered?(type) ⇒ Boolean
Check if a type is registered.
-
.types ⇒ Array<Symbol>
Get all registered element types.
Class Method Details
.config_for(type) ⇒ Hash?
Get configuration for a specific type
89 90 91 |
# File 'lib/lutaml/cli/resource_registry.rb', line 89 def self.config_for(type) TYPES[type.to_sym] end |
.description_for(type) ⇒ String
Get description for a type
114 115 116 117 |
# File 'lib/lutaml/cli/resource_registry.rb', line 114 def self.description_for(type) config = config_for(type) config ? config[:description] : "" end |
.icon_for(type) ⇒ String
Get icon for a type
105 106 107 108 |
# File 'lib/lutaml/cli/resource_registry.rb', line 105 def self.icon_for(type) config = config_for(type) config ? config[:icon] : "" end |
.type_descriptions ⇒ Hash<Symbol, String>
Get all types with their descriptions
122 123 124 |
# File 'lib/lutaml/cli/resource_registry.rb', line 122 def self.type_descriptions TYPES.transform_values { |config| config[:description] } end |
.type_registered?(type) ⇒ Boolean
Check if a type is registered
97 98 99 |
# File 'lib/lutaml/cli/resource_registry.rb', line 97 def self.type_registered?(type) TYPES.key?(type.to_sym) end |
.types ⇒ Array<Symbol>
Get all registered element types
81 82 83 |
# File 'lib/lutaml/cli/resource_registry.rb', line 81 def self.types TYPES.keys end |