Sha256: 0090fb00a8597d8437335b5e01ba357796dc5e429182a7292a2674856db58bd1

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 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)))
        resize(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

1 entries across 1 versions & 1 rubygems

Version Path
mm-attach-it-0.1.2 lib/attach_it/storage/filesystem.rb