Class: Mxrb::Compiler::ClientModelMaterializer

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

Overview

Materializes Runtime page descriptors and navigation documents.

Constant Summary collapse

TYPES =
%w[Forms$Page Navigation$NavigationDocument].freeze

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, deployment:) ⇒ ClientModelMaterializer

Returns a new instance of ClientModelMaterializer.



11
12
13
14
# File 'lib/mxrb/compiler/client_model_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
23
24
25
26
# File 'lib/mxrb/compiler/client_model_materializer.rb', line 16

def materialize
  source = SourceModel.read(@mpr_path)
  path = File.join(@deployment, 'model', 'model.mdp')
  package = ModelPackage.read(path)
  pages = source.units_of('Forms$Page').map { PageDocumentCompiler.new(source).compile(_1) }
  navigation = compile_navigation(source, package)
  write(path, package, pages + navigation)
  ClientModelMaterialization.new(
    model_path: path, pages: pages.length, navigation_documents: navigation.length
  )
end