Sha256: 636a2d4d0c2a81153aacca920b5f1ccdbe2ee35de0a8051117d9dc966d3710ed

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

require_relative 'deflater_base'

module Paperclip
  module Processors
    class Deflater < DeflaterBase
      def initialize(file, options = {}, attachment = nil)
        super
        @deflate_options = @options[:deflate_options] || {}
      end

      def make
        level       = @deflate_options[:level]
        window_bits = @deflate_options[:window_bits]
        memlevel    = @deflate_options[:memlevel]
        strategy    = @deflate_options[:strategy]

        dst = create_tempfile
        zd = Zlib::Deflate.new(level, window_bits, memlevel, strategy)
        dst.write zd.deflate(@file.read)
        zd.close
        dst.flush
        dst.rewind

        dst
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paperclip-deflater-0.0.6 lib/paperclip/processors/deflater.rb
paperclip-deflater-0.0.4 lib/paperclip/processors/deflater.rb