Class: Mxrb::Compiler::ConstantsMaterializer

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/compiler/constants_materializer.rb

Overview

Compiles MPR constants into Runtime model and metadata representations.

Constant Summary collapse

DATA_TYPES =
{
  'DataTypes$StringType' => 'String', 'DataTypes$IntegerType' => 'Integer',
  'DataTypes$BooleanType' => 'Boolean', 'DataTypes$DecimalType' => 'Decimal',
  'DataTypes$DateTimeType' => 'DateTime'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, deployment:) ⇒ ConstantsMaterializer

Returns a new instance of ConstantsMaterializer.



19
20
21
22
# File 'lib/mxrb/compiler/constants_materializer.rb', line 19

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

Instance Method Details

#materializeObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mxrb/compiler/constants_materializer.rb', line 24

def materialize
  source = SourceModel.read(@mpr_path)
  constants = compile(source)
  model_path = File.join(@deployment, 'model', 'model.mdp')
   = File.join(@deployment, 'model', 'metadata.json')
  write_model(model_path, constants)
   = (, constants)
  ConstantsMaterialization.new(
    model_path:, metadata_path:, constants: .freeze
  )
end