Sha256: 1da81d5de8af345de42906b47e01c8a17665e53587362b1f6c6216ba3bc29e16

Contents?: true

Size: 801 Bytes

Versions: 3

Compression:

Stored size: 801 Bytes

Contents

module Powerpoint
  def self.decompress_pptx(in_path, out_path)
    Zip::File.open(in_path) do |zip_file|
      zip_file.each do |f|
        f_path = File.join(out_path, f.name)
        FileUtils.mkdir_p(File.dirname(f_path))
        zip_file.extract(f, f_path) unless File.exist?(f_path)
      end
    end
  end

  def self.compress_pptx(in_path, out_path)
    Zip::File.open(out_path, Zip::File::CREATE) do |zip_file|
      Dir.glob("#{in_path}/**/*", ::File::FNM_DOTMATCH).each do |path|
        zip_path = path.gsub("#{in_path}/","")
        next if zip_path == "." || zip_path == ".." || zip_path.match(/DS_Store/)
        begin
          zip_file.add(zip_path, path)
        rescue Zip::ZipEntryExistsError
          raise "#{out_path} already exists!"
        end
      end
    end
  end  
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
powerpoint-pro-2.1.0.1 lib/powerpoint/compression.rb
powerpoint-1.8 lib/powerpoint/compression.rb
powerpoint-1.7 lib/powerpoint/compression.rb