Class: Expressir::Package::Builder

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

Overview

Builds LER packages from Repository instances Single responsibility: Create .ler ZIP packages

Instance Method Summary collapse

Instance Method Details

#build(repository, output_path, options = {}) ⇒ String

Build LER package from repository

Parameters:

  • repository (Model::Repository)

    Repository to package

  • output_path (String)

    Output .ler file path

  • options (Hash) (defaults to: {})

    Package options

Options Hash (options):

  • :name (String)

    Package name

  • :version (String)

    Package version

  • :description (String)

    Package description

  • :express_mode (String) — default: 'include_all'

    Bundling mode

  • :resolution_mode (String) — default: 'resolved'

    Resolution mode

  • :serialization_format (String) — default: 'marshal'

    Serialization format

Returns:

  • (String)

    Path to created package



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

def build(repository, output_path, options = {})
  options = normalize_options(options)
   = (repository, options)

  # Validate metadata
  validation = .validate
  unless validation[:valid?]
    raise ArgumentError,
          "Invalid metadata: #{validation[:errors].join(', ')}"
  end

  # Create ZIP package
  Zip::File.open(output_path, Zip::File::CREATE) do |zip|
    (zip, )
    add_schemas(zip, repository, options)
    add_indexes(zip, repository)
    add_manifest(zip, repository)
  end

  output_path
end