class ALD::Package
Represents an ALD package file containing an app or library and its definition.
Public
↑ topAttributes
The ALD::Definition instance representing the definition contained in the package. Use this to extract all the information on the package.
Public Class Methods
Opens a new ALD package file.
- file
-
a String representing the path to the file or a Zip::File instance
Returns¶ ↑
Returns a new ALD::Package instance representing the package file
Raises ALD::NoDefinitionError if the package contains no definition file.
Raises ALD::InvalidPackageError if the package is not valid according to its definition.
# File lib/ALD/package.rb, line 27 def initialize(file) if file.is_a? Zip::File @archive = file else @archive = Zip::File.open(file) end def_entry = @archive.find_entry('definition.ald') raise NoDefinitionError if def_entry.nil? @definition = Definition.new(def_entry.get_input_stream) raise InvalidPackageError, 'The given ZIP file is not a valid ALD archive!' unless Package.valid?(@archive, @definition) # todo: file access end
Alias for ::new
# File lib/ALD/package.rb, line 53 def self.open(file) new(file) end
Tests if a given archive is a valid ALD package. Although part of the public API, most library consumers will not need to call it, as it is already called by ::new.
Not yet implemented.
- file
-
a Zip::File instance for the package
- definition
-
an ALD::Definition instance the package must meet
Returns¶ ↑
Returns true if it is valid, false otherwise
# File lib/ALD/package.rb, line 67 def self.valid?(file, definition) true # todo end
Public Instance Methods
Internal
↑ topAttributes
The rubyzip Zip::File object containing the data.