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.



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

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



181
182
183
184
185
186
187
188
# File 'lib/mxrb/official_marketplace/module_package_importer.rb', line 181

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