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

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mxrb/compiler/packager.rb', line 22

def pack(output:, force: false) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  Progress.with("Packing #{File.basename(@mpr_path)}") do |progress|
    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
    progress.update(
      current: 3, total: files.size + directories.size + 4,
      detail: "#{files.size} files"
    )
    write_atomically(output_path, files, directories, progress)
    package_result(output_path, version, ).tap do
      progress.advance(detail: 'package checksum')
    end
  end
end