Class: Lutaml::UmlRepository::StaticSite::DataTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/uml_repository/static_site/data_transformer.rb

Overview

Transforms a UmlRepository into a normalized JSON data structure optimized for client-side navigation and search.

The output follows a normalized structure with:

  • Flat maps for packages, classes, attributes, associations

  • References by stable IDs

  • Hierarchical package tree for navigation

Examples:

repository = UmlRepository.from_package("model.lur")
transformer = DataTransformer.new(repository)
json_data = transformer.transform

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, options = {}) ⇒ DataTransformer

Initialize transformer

information as markdown

Parameters:

  • repository (UmlRepository)

    The repository to transform

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

    Transformation options

Options Hash (options):

  • :include_diagrams (Boolean)

    Include diagram

  • :format_definitions (Boolean)

    Format definitions



31
32
33
34
35
36
# File 'lib/lutaml/uml_repository/static_site/data_transformer.rb', line 31

def initialize(repository, options = {})
  @repository = repository
  @options = default_options.merge(options)
  @id_generator = IDGenerator.new
  @generalization_map = build_generalization_map
end

Instance Attribute Details

#id_generatorObject (readonly)

Returns the value of attribute id_generator.



21
22
23
# File 'lib/lutaml/uml_repository/static_site/data_transformer.rb', line 21

def id_generator
  @id_generator
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/lutaml/uml_repository/static_site/data_transformer.rb', line 21

def options
  @options
end

#repositoryObject (readonly)

Returns the value of attribute repository.



21
22
23
# File 'lib/lutaml/uml_repository/static_site/data_transformer.rb', line 21

def repository
  @repository
end

Instance Method Details

#transformHash

Transform repository to JSON structure

Returns:

  • (Hash)

    Normalized JSON data structure



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/lutaml/uml_repository/static_site/data_transformer.rb', line 41

def transform
  {
    metadata: ,
    packageTree: build_package_tree,
    packages: build_packages_map,
    classes: build_classes_map,
    attributes: build_attributes_map,
    associations: build_associations_map,
    operations: build_operations_map,
    diagrams: (@options[:include_diagrams] ? build_diagrams_map : {}),
  }
end