Sha256: d93604248ed98be375d660e86ede6d58915d2cc26aee01d8f99fbd5558864ff0

Contents?: true

Size: 964 Bytes

Versions: 7

Compression:

Stored size: 964 Bytes

Contents

class Filesystem < Storage

  def flush_write(image_options = nil)
    image_options.styles.each do |style_name, style_value|
      begin        
        FileUtils.mkdir_p(File.dirname(image_options.path(style_name)))
        transform(style_value, image_options.assigned_file.path).write(image_options.path(style_name)) 
        FileUtils.chmod(0644, image_options.path(style_name))
      rescue Exception => exception
        image_options.add_error(exception.to_s)
      end
    end

    unless image_options.styles.has_key?(:original)
      begin
        FileUtils.mkdir_p(File.dirname(image_options.path(:original)))
        FileUtils.cp(image_options.assigned_file.path, image_options.path(:original)) 
      rescue Exception => exception
        image_options.add_error(exception.to_s)
      end
    end
  end

  def flush_delete(queued_for_delete = nil)
    queued_for_delete.each do |file|
      FileUtils.rm(file) if File.exist?(file)
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mm-attach-it-0.2.3 lib/attach_it/storage/filesystem.rb
mm-attach-it-0.2.2 lib/attach_it/storage/filesystem.rb
mm-attach-it-0.2.1 lib/attach_it/storage/filesystem.rb
mm-attach-it-0.2.0 lib/attach_it/storage/filesystem.rb
mm-attach-it-0.1.5 lib/attach_it/storage/filesystem.rb
mm-attach-it-0.1.4 lib/attach_it/storage/filesystem.rb
mm-attach-it-0.1.3 lib/attach_it/storage/filesystem.rb