Module: Lutaml::ModelTransformations

Defined in:
lib/lutaml/model_transformations.rb,
lib/lutaml/model_transformations/configuration.rb,
lib/lutaml/model_transformations/format_registry.rb,
lib/lutaml/model_transformations/parsers/qea_parser.rb,
lib/lutaml/model_transformations/parsers/xmi_parser.rb,
lib/lutaml/model_transformations/parsers/base_parser.rb,
lib/lutaml/model_transformations/transformation_engine.rb

Overview

Model Transformations module provides a unified, extensible system for transforming various UML model formats (XMI, QEA, etc.) into a common UML document representation.

This module follows SOLID principles and implements:

  • Single Responsibility: Each component has one clear purpose

  • Open/Closed: Easy to extend with new formats without modifying existing

code

  • Liskov Substitution: All parsers implement the same interface

  • Interface Segregation: Clients depend only on methods they use

  • Dependency Inversion: Depends on abstractions, not concrete

implementations

Examples:

Parse any supported format

engine = Lutaml::ModelTransformations::TransformationEngine.new
document = engine.parse("model.xmi")
document = engine.parse("model.qea")

Register custom parser

engine.register_parser(".custom", MyCustomParser)
document = engine.parse("model.custom")

Use custom configuration

config = Lutaml::ModelTransformations::Configuration.load("my_config.yml")
engine = Lutaml::ModelTransformations::TransformationEngine.new(config)

Defined Under Namespace

Modules: Parsers Classes: Configuration, FormatRegistry, TransformationEngine, UnsupportedFormatError

Class Method Summary collapse

Class Method Details

.configurationConfiguration

Get current configuration

Returns:



125
126
127
# File 'lib/lutaml/model_transformations.rb', line 125

def configuration
  engine.configuration
end

.configuration=(config) ⇒ Object

Set configuration

Parameters:



132
133
134
# File 'lib/lutaml/model_transformations.rb', line 132

def configuration=(config)
  engine.configuration = config
end

.configure {|config| ... } ⇒ Object

Configure using a block

Yield Parameters:



138
139
140
# File 'lib/lutaml/model_transformations.rb', line 138

def configure
  yield(configuration) if block_given?
end

.detect_parser(file_path) ⇒ Class

Auto-detect file format and return appropriate parser

Parameters:

  • file_path (String)

    Path to the model file

Returns:

  • (Class)

    The parser class for the file format



70
71
72
# File 'lib/lutaml/model_transformations.rb', line 70

def detect_parser(file_path)
  engine.detect_parser(file_path)
end

.engineTransformationEngine

Get the default transformation engine

Returns:



46
47
48
# File 'lib/lutaml/model_transformations.rb', line 46

def engine
  @engine ||= TransformationEngine.new
end

.engine=(engine) ⇒ Object

Set a custom transformation engine

Parameters:



53
54
55
# File 'lib/lutaml/model_transformations.rb', line 53

def engine=(engine)
  @engine = engine
end

.load_configuration(config_path) ⇒ Configuration

Load configuration from file

Parameters:

  • config_path (String)

    Path to configuration file

Returns:



118
119
120
# File 'lib/lutaml/model_transformations.rb', line 118

def load_configuration(config_path)
  engine.configuration = Configuration.load(config_path)
end

.parse(file_path, options = {}) ⇒ Lutaml::Uml::Document

Parse a model file using the default engine

Parameters:

  • file_path (String)

    Path to the model file

  • options (Hash) (defaults to: {})

    Parsing options

Returns:



62
63
64
# File 'lib/lutaml/model_transformations.rb', line 62

def parse(file_path, options = {})
  engine.parse(file_path, options)
end

.register_parser(extension, parser_class) ⇒ Object

Register a custom parser for a file extension

interface

Parameters:

  • extension (String)

    File extension (e.g., “.custom”)

  • parser_class (Class)

    Parser class implementing BaseParser



110
111
112
# File 'lib/lutaml/model_transformations.rb', line 110

def register_parser(extension, parser_class)
  engine.register_parser(extension, parser_class)
end

.reset_statisticsObject

Reset transformation statistics



96
97
98
# File 'lib/lutaml/model_transformations.rb', line 96

def reset_statistics
  engine.clear_history
end

.statisticsHash

Get transformation statistics

Returns:

  • (Hash)

    Statistics data



91
92
93
# File 'lib/lutaml/model_transformations.rb', line 91

def statistics
  engine.statistics
end

.supported_extensionsArray<String>

Get list of supported file extensions

Returns:

  • (Array<String>)

    List of supported extensions



77
78
79
# File 'lib/lutaml/model_transformations.rb', line 77

def supported_extensions
  engine.supported_extensions
end

.supports_file?(file_path) ⇒ Boolean

Check if a file is supported

Parameters:

  • file_path (String)

    Path to the model file

Returns:

  • (Boolean)


84
85
86
# File 'lib/lutaml/model_transformations.rb', line 84

def supports_file?(file_path)
  engine.supports_file?(file_path)
end

.validate_setupObject

Validate setup of the transformation engine



101
102
103
# File 'lib/lutaml/model_transformations.rb', line 101

def validate_setup
  engine.validate_setup
end