module Paperclip

def self.current_attachments_styles

}
}
:sample => [:thumb, :big]},
:cover => [:thumb, :croppable]},
:Book => {
:User => {:avatar => [:small, :big]},
{
Unfortunately current version does not work with lambda styles:(
Returns hash with styles for all classes using Paperclip.
def self.current_attachments_styles
  Hash.new.tap do |current_styles|
    Paperclip::AttachmentRegistry.each_definition do |klass, attachment_name, attachment_attributes|
      # TODO: is it even possible to take into account Procs?
      next if attachment_attributes[:styles].kind_of?(Proc)
      attachment_attributes[:styles].try(:keys).try(:each) do |style_name|
        klass_sym = klass.to_s.to_sym
        current_styles[klass_sym] ||= Hash.new
        current_styles[klass_sym][attachment_name.to_sym] ||= Array.new
        current_styles[klass_sym][attachment_name.to_sym] << style_name.to_sym
        current_styles[klass_sym][attachment_name.to_sym].map!(&:to_s).sort!.map!(&:to_sym).uniq!
      end
    end
  end
end

def self.get_registered_attachments_styles

Get list of styles saved on previous deploy (running rake paperclip:refresh:missing_styles)
def self.get_registered_attachments_styles
  YAML.load_file(Paperclip.registered_attachments_styles_path)
rescue Errno::ENOENT
  nil
end

def self.io_adapters

def self.io_adapters
  @io_adapters ||= Paperclip::AdapterRegistry.new
end

def self.io_adapters=(new_registry)

def self.io_adapters=(new_registry)
  @io_adapters = new_registry
end

def self.missing_attachments_styles

}
}
:cover => [:croppable]},
:Book => {
:User => {:avatar => [:big]},
{
Returns hash with styles missing from recent run of rake paperclip:refresh:missing_styles
def self.missing_attachments_styles
  current_styles = current_attachments_styles
  registered_styles = get_registered_attachments_styles
  Hash.new.tap do |missing_styles|
    current_styles.each do |klass, attachment_definitions|
      attachment_definitions.each do |attachment_name, styles|
        registered = registered_styles[klass][attachment_name] || [] rescue []
        missed = styles - registered
        if missed.present?
          klass_sym = klass.to_s.to_sym
          missing_styles[klass_sym] ||= Hash.new
          missing_styles[klass_sym][attachment_name.to_sym] ||= Array.new
          missing_styles[klass_sym][attachment_name.to_sym].concat(missed.to_a)
          missing_styles[klass_sym][attachment_name.to_sym].map!(&:to_s).sort!.map!(&:to_sym).uniq!
        end
      end
    end
  end
end

def self.options

image's orientation. Defaults to true.
* use_exif_orientation: Whether to inspect EXIF data to determine an
nil, which uses the first executable found in the user's search path.
programs if they are not visible to Rails the system's search path. Defaults to
* command_path: Defines the path at which to find the command line
log levels, etc. Defaults to true.
* log: Logs progress to the Rails log. Uses ActiveRecord's logger, so honors
an uploaded image. Defaults to true.
* whiny: Will raise an error if Paperclip cannot process thumbnails of
Provides configurability to Paperclip. The options available are:
def self.options
  @options ||= {
    command_path: nil,
    content_type_mappings: {},
    log: true,
    log_command: true,
    read_timeout: nil,
    swallow_stderr: true,
    use_exif_orientation: true,
    whiny: true,
    is_windows: Gem.win_platform?
  }
end

def self.save_current_attachments_styles!

def self.save_current_attachments_styles!
  File.open(Paperclip.registered_attachments_styles_path, 'w') do |f|
    YAML.dump(current_attachments_styles, f)
  end
end

def registered_attachments_styles_path

def registered_attachments_styles_path
  @registered_attachments_styles_path ||= Rails.root.join('public/system/paperclip_attachments.yml').to_s
end