Sha256: 09bd23214e633f27178bc5269aa56fadfe716790739bef1ce0bd58774cffb8e0

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

module Pione
  module Package
    # PackageExpander expands package files from ZIP archive.
    class PackageExpander
      attr_reader :location

      # Create a instance with the target location.
      #
      # @param location [BasicLoaction]
      #   package location
      def initialize(location)
        @location = location
      end

      # Expand package files into the output location.
      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

      def valid_filename?
        filename = @location.basename
        if File.extname(filename) == ".ppg"
          identifiers = filename.split("-")
          identifiers[1]
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pione-0.5.0 lib/pione/package/package-expander.rb
pione-0.5.0.alpha.2 lib/pione/package/package-expander.rb
pione-0.5.0.alpha.1 lib/pione/package/package-expander.rb
pione-0.4.2 lib/pione/package/package-expander.rb
pione-0.4.1 lib/pione/package/package-expander.rb
pione-0.4.0 lib/pione/package/package-expander.rb
pione-0.3.2 lib/pione/package/package-expander.rb
pione-0.3.1 lib/pione/package/package-expander.rb
pione-0.3.0 lib/pione/package/package-expander.rb