Sha256: 024ecc7a37ed6bd4b4077ef1bc2d2881cf302def234a676fc954a56f5f4b7d2f

Contents?: true

Size: 917 Bytes

Versions: 19

Compression:

Stored size: 917 Bytes

Contents

module PopulateMe

  class Variation < Struct.new :name, :ext, :job
        
    # Simple class to deal with variations of an attachment
    # Mainly variation of images using ImageMagick
    # but it could be anything else like creating the pdf version
    # of a text file

    def initialize name, ext, job_as_proc=nil, &job_as_block
      super name, ext, job_as_proc||job_as_block
    end

    class << self

      def new_image_magick_job name, ext, convert_string, options={}
        o = {
          strip: true, progressive: true,
        }.merge(options)
        defaults = ""
        defaults << "-strip " if o[:strip]
        defaults << "-interlace Plane " if o[:progressive] and [:jpg,:jpeg].include?(ext.to_sym)
        job = lambda{ |src,dst|
          Kernel.system "convert \"#{src}\" #{defaults}#{convert_string} \"#{dst}\""
        }
        self.new name, ext, job
      end

    end

  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
populate-me-0.6.3 lib/populate_me/variation.rb
populate-me-0.6.2 lib/populate_me/variation.rb
populate-me-0.6.1 lib/populate_me/variation.rb
populate-me-0.6.0 lib/populate_me/variation.rb
populate-me-0.5.2 lib/populate_me/variation.rb
populate-me-0.5.1 lib/populate_me/variation.rb
populate-me-0.5.0 lib/populate_me/variation.rb
populate-me-0.4.0 lib/populate_me/variation.rb
populate-me-0.3.0 lib/populate_me/variation.rb
populate-me-0.2.0 lib/populate_me/variation.rb
populate-me-0.1.8 lib/populate_me/variation.rb
populate-me-0.1.7 lib/populate_me/variation.rb
populate-me-0.1.6 lib/populate_me/variation.rb
populate-me-0.1.5 lib/populate_me/variation.rb
populate-me-0.1.4 lib/populate_me/variation.rb
populate-me-0.1.3 lib/populate_me/variation.rb
populate-me-0.1.2 lib/populate_me/variation.rb
populate-me-0.1.1 lib/populate_me/variation.rb
populate-me-0.1.0 lib/populate_me/variation.rb