Class: Mxrb::OfficialMarketplace::WidgetPackageInventory
- Inherits:
-
Object
- Object
- Mxrb::OfficialMarketplace::WidgetPackageInventory
- Defined in:
- lib/mxrb/official_marketplace/widget_package_installer.rb
Overview
Read-only, fail-closed inventory for a clientModule MPK. rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#project_filename ⇒ Object
readonly
Returns the value of attribute project_filename.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#widget_ids ⇒ Object
readonly
Returns the value of attribute widget_ids.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, version:, widget_ids:, project_filename:) ⇒ WidgetPackageInventory
constructor
A new instance of WidgetPackageInventory.
Constructor Details
#initialize(name:, version:, widget_ids:, project_filename:) ⇒ WidgetPackageInventory
Returns a new instance of WidgetPackageInventory.
41 42 43 44 45 46 |
# File 'lib/mxrb/official_marketplace/widget_package_installer.rb', line 41 def initialize(name:, version:, widget_ids:, project_filename:) @name = name @version = version @widget_ids = .freeze @project_filename = project_filename end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/mxrb/official_marketplace/widget_package_installer.rb', line 39 def name @name end |
#project_filename ⇒ Object (readonly)
Returns the value of attribute project_filename.
39 40 41 |
# File 'lib/mxrb/official_marketplace/widget_package_installer.rb', line 39 def project_filename @project_filename end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
39 40 41 |
# File 'lib/mxrb/official_marketplace/widget_package_installer.rb', line 39 def version @version end |
#widget_ids ⇒ Object (readonly)
Returns the value of attribute widget_ids.
39 40 41 |
# File 'lib/mxrb/official_marketplace/widget_package_installer.rb', line 39 def @widget_ids end |
Class Method Details
.read(path) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mxrb/official_marketplace/widget_package_installer.rb', line 48 def self.read(path) Zip::File.open(path) do |archive| validate_entries!(archive) document = package_document(archive) clients = elements(document.root, 'clientModule') raise MarketplaceError, 'package.xml must declare exactly one clientModule' unless clients.one? client = clients.first name = valid_name(client.attributes['name']) version = valid_version(client.attributes['version']) = elements(client, 'widgetFile').map do |element| safe_relative_path(element.attributes['path']) end.uniq raise MarketplaceError, 'widget package does not declare widgetFiles' if .empty? validate_declared_files!(archive, client) = .map { (archive, _1) } filename = project_filename(name, ) new(name:, version:, widget_ids:, project_filename: filename) end rescue Zip::Error, REXML::ParseException => e raise MarketplaceError, "invalid Mendix widget package: #{e.}" end |