Class: Mxrb::Compiler::SystemTextMaterializer

Inherits:
Object
  • Object
show all
Includes:
ModelValues
Defined in:
lib/mxrb/compiler/system_text_materializer.rb

Overview

Stores the Runtime system-text index; localized values live in i18n properties.

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, deployment:) ⇒ SystemTextMaterializer

Returns a new instance of SystemTextMaterializer.



11
12
13
14
# File 'lib/mxrb/compiler/system_text_materializer.rb', line 11

def initialize(mpr_path, deployment:)
  @mpr_path = File.expand_path(mpr_path)
  @deployment = File.expand_path(deployment)
end

Instance Method Details

#materializeObject



16
17
18
19
20
21
22
# File 'lib/mxrb/compiler/system_text_materializer.rb', line 16

def materialize
  source = SourceModel.read(@mpr_path).units_of('Texts$SystemTextCollection').first
  document = source ? compile(source.document) : empty_collection
  path = File.join(@deployment, 'model', 'model.mdp')
  ModelPackage.read(path).upsert(document).write(path)
  SystemTextMaterialization.new(model_path: path, texts: document.fetch('SystemTexts').length)
end