Class: Mxrb::Compiler::Packager

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

Overview

Pure-Ruby MDA container writer. This first compiler stage packages an already materialized deployment and never invokes mx or mxbuild.

Constant Summary collapse

FIXED_TIME =
Time.utc(2000, 1, 1).freeze

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, deployment: nil) ⇒ Packager

Returns a new instance of Packager.



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

def initialize(mpr_path, deployment: nil)
  @mpr_path = File.expand_path(mpr_path)
  @project_root = File.dirname(@mpr_path)
  @deployment = File.expand_path(deployment || File.join(@project_root, 'deployment'))
end

Instance Method Details

#pack(output:, force: false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mxrb/compiler/packager.rb', line 22

def pack(output:, force: false)
  output_path = File.expand_path(output)
  validate_input!(output_path, force:)
  version = Mxrb.open(@mpr_path, &:mendix_version)
  adapter = Adapter.for(version)
   = adapter.validate_deployment!(@deployment)
  adapter.validate_freshness!(@mpr_path, @deployment)
  files, directories = inventory
  write_atomically(output_path, files, directories)
  package_result(output_path, version, )
end