Class: Lutaml::UmlRepository::PackageLoader
- Inherits:
-
Object
- Object
- Lutaml::UmlRepository::PackageLoader
- Defined in:
- lib/lutaml/uml_repository/package_loader.rb
Overview
PackageLoader handles loading UmlRepository instances from LUR (LutaML UML Repository) package files.
LUR packages are ZIP archives that contain pre-serialized repositories for fast loading without re-parsing XMI files.
Class Method Summary collapse
-
.load(lur_path) ⇒ UmlRepository
Load a UmlRepository from a LUR package file.
-
.load_document_only(lur_path) ⇒ LazyRepository
Load only the document from a LUR package without building indexes.
Class Method Details
.load(lur_path) ⇒ UmlRepository
Load a UmlRepository from a LUR package file.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lutaml/uml_repository/package_loader.rb', line 28 def self.load(lur_path) # rubocop:disable Metrics/MethodLength unless File.exist?(lur_path) raise ArgumentError, "Package file not found: #{lur_path}" end document = nil indexes = nil = nil begin Zip::File.open(lur_path) do |zip| # Read metadata (now returns PackageMetadata) = (zip) # Load Document based on format document = load_document(zip, ) # Load indexes indexes = load_indexes(zip) end rescue Zip::Error => e raise "Invalid LUR package: #{e.}" rescue StandardError => e raise "Failed to load package: #{e.}" end # Create repository with loaded data and metadata Repository.new(document: document, indexes: indexes, metadata: ) end |
.load_document_only(lur_path) ⇒ LazyRepository
Load only the document from a LUR package without building indexes.
This method loads the document but does not load or build indexes, returning a LazyRepository instance that will build indexes on-demand.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/lutaml/uml_repository/package_loader.rb', line 69 def self.load_document_only(lur_path) # rubocop:disable Metrics/MethodLength unless File.exist?(lur_path) raise ArgumentError, "Package file not found: #{lur_path}" end document = nil = nil begin Zip::File.open(lur_path) do |zip| # Read metadata (now returns PackageMetadata) = (zip) # Load Document based on format document = load_document(zip, ) end rescue Zip::Error => e raise "Invalid LUR package: #{e.}" rescue StandardError => e raise "Failed to load package: #{e.}" end # Create lazy repository without indexes but with metadata require_relative "../lazy_repository" LazyRepository.new(document: document, lazy: true, metadata: ) end |