Class: Expressir::Package::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/expressir/package/reader.rb

Overview

Loads LER packages into Repository instances Single responsibility: Load .ler ZIP packages

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(package_path) ⇒ Model::Repository

Load repository from LER package

Parameters:

  • package_path (String)

    Path to .ler file

Returns:



14
15
16
# File 'lib/expressir/package/reader.rb', line 14

def self.load(package_path)
  new.load(package_path)
end

Instance Method Details

#load(package_path) ⇒ Model::Repository

Load repository from LER package

Parameters:

  • package_path (String)

    Path to .ler file

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/expressir/package/reader.rb', line 21

def load(package_path)
  unless File.exist?(package_path)
    raise ArgumentError, "Package file not found: #{package_path}"
  end

  repository = nil
   = nil

  Zip::File.open(package_path) do |zip|
    # Read metadata first
     = (zip)

    # Load repository based on resolution mode
    repository = if .resolution_mode == "resolved"
                   load_serialized_repository(zip,
                                              .serialization_format)
                 else
                   load_from_express_files(zip)
                 end

    # Load and restore indexes
    load_indexes(zip, repository)
  end

  repository
end