class ALD::Package::Generator

Attributes

definition[W]

Public Class Methods

from_package(package) click to toggle source
# File lib/ALD/package_generator.rb, line 49
def self.from_package(package)
  nil
end

Public Instance Methods

definition() click to toggle source
# File lib/ALD/package_generator.rb, line 11
def definition
  if @definition.is_a? ALD::Definition
    @definition
  elsif @definition.is_a? ALD::Definition::Generator
    @definition.generate!
  end
end
generate!(path) click to toggle source

Creates a new package file from the given data

generator

an ALD::Package::Generator instance to create the package from

path

the path where to create the package. This file must not yet exist.

Returns

Returns a new ALD::Package instance representing the newly created file

# File lib/ALD/package_generator.rb, line 29
def generate!(path)
  if File.exists? path
    raise IOError, "Destination '#{path}' already exists!"
  end

  raise InvalidPackageError unless valid?

  archive = Zip::File.open(path, Zip::File::CREATE)

  archive.get_output_stream('definition.ald') do |s|
    s << definition.to_s
  end

  files.each do |path, src|
    archive.add(path, src)
  end

  Package.new(file)
end
valid?() click to toggle source
# File lib/ALD/package_generator.rb, line 19
def valid?
  true && @definition.valid?
end