Class: Lutaml::UmlRepository::StaticSite::Generator

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

Overview

Orchestrates static site generation.

Thin coordinator that delegates to:

  • DataTransformer for building the typed SpaDocument

  • SearchIndexBuilder for building the typed SpaSearchIndex

  • Output::Strategy subclass for rendering HTML

Examples:

Single-file Vue IIFE output

generator = Generator.new(repository,
  output_strategy: Output::VueInlinedStrategy,
  output: "browser.html")
generator.generate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Generator.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 24

def initialize(repository, options = {})
  @repository = repository
  @config = options[:config] ||
    Configuration.load(options[:config_path])
  @options = build_options(options)

  @id_generator = options[:id_generator] || IdGenerator.new
  @data_transformer = options[:data_transformer] ||
    create_data_transformer
  @search_builder = options[:search_builder] ||
    create_search_builder

  @output_strategy = resolve_strategy(options)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#data_transformerObject (readonly)

Returns the value of attribute data_transformer.



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

def data_transformer
  @data_transformer
end

#id_generatorObject (readonly)

Returns the value of attribute id_generator.



21
22
23
# File 'lib/lutaml/uml_repository/static_site/generator.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/generator.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/generator.rb', line 21

def repository
  @repository
end

#search_builderObject (readonly)

Returns the value of attribute search_builder.



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

def search_builder
  @search_builder
end

Instance Method Details

#generateObject



39
40
41
42
43
44
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 39

def generate
  spa_document = @data_transformer.transform
  search_index = @search_builder.build

  @output_strategy.render(spa_document, search_index)
end