Class: Mxrb::OfficialMarketplace::ModulePackageImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/official_marketplace/module_package_importer.rb

Overview

Imports a Mendix module package directly into an MPR without Studio Pro.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(package_path, mpr_path, target_root: nil, allow_model_upgrade: false, protected_files: []) ⇒ ModulePackageImporter

Returns a new instance of ModulePackageImporter.



173
174
175
176
177
178
179
180
# File 'lib/mxrb/official_marketplace/module_package_importer.rb', line 173

def initialize(package_path, mpr_path, target_root: nil, allow_model_upgrade: false,
               protected_files: [])
  @package_path = File.expand_path(package_path)
  @mpr_path = File.expand_path(mpr_path)
  @target_root = File.expand_path(target_root || File.dirname(@mpr_path))
  @allow_model_upgrade = allow_model_upgrade
  @protected_files = protected_files
end

Instance Method Details

#import!Object



182
183
184
185
186
187
188
189
190
191
192
# File 'lib/mxrb/official_marketplace/module_package_importer.rb', line 182

def import!
  Progress.with("Importing #{File.basename(@package_path)}") do |progress|
    validate_inputs!
    progress.update(detail: 'reading package')
    Dir.mktmpdir('mxrb-module-import-') do |temporary|
      Zip::File.open(@package_path) { import_archive(_1, temporary, progress) }
    end
  end
rescue Zip::Error, REXML::ParseException => e
  raise MarketplaceError, "invalid Mendix module package: #{e.message}"
end