class Pione::Package::PackageExpander

PackageExpander expands package files from ZIP archive.

Attributes

location[R]

Public Class Methods

new(location) click to toggle source

Create a instance with the target location.

@param location [BasicLoaction]

package location
# File lib/pione/package/package-expander.rb, line 11
def initialize(location)
  @location = location
end

Public Instance Methods

expand(output) click to toggle source

Expand package files into the output location.

# File lib/pione/package/package-expander.rb, line 16
def expand(output)
  # make local cache of target location
  location = @location.local

  # expand zip archive
  Zip::File.open(location.path.to_s) do |zip|
    zip.each do |entry|
      unless entry.ftype == :directory
        tmp = Temppath.create
        entry.extract(tmp.to_s)
        Location[tmp].move(output + entry.name)
      end
    end
  end
end

Private Instance Methods

valid_filename?() click to toggle source
# File lib/pione/package/package-expander.rb, line 34
def valid_filename?
  filename = @location.basename
  if File.extname(filename) == ".ppg"
    identifiers = filename.split("-")
    identifiers[1]
  end
end