<commit_before>h1. Delayed::Paperclip

Delayed_paperclip lets you process your "Paperclip":http://github.com/thoughtbot/paperclip attachments in a background task with "delayed_job":http://github.com/tobi/delayed_job.

This is a fork that focuses on "Resque":http://github.com/defunkt/resque rather than Delayed::Job.  Everyone says that "they are both awesome":http://github.com/blog/542-introducing-resque, but, in my case, I'm already committed to using "Vanity":http://vanity.labnotes.org/ and, I'm no expert, but "redis and Vanity":http://groups.google.com/group/vanity-talk/browse_thread/thread/db6c106581a26c46/eccff9396bdb2fe8?show_docid=eccff9396bdb2fe8&fwc=1&pli=1# look like they're likely to go hand in hand for some time.  

h2. Why?

The "original author":http://github.com/jstorimer/delayed_paperclip says:

bq. The most common use case for Paperclip is to easily attach image files to ActiveRecord models. Most of the time these image files will have multiple styles and will need to be resized when they are created. This is usually a pretty "slow operation":http://www.jstorimer.com/ruby/2010/01/05/speep-up-your-paperclip-tests.html and should be handled in a background task. 

bq. I'm sure that everyone knows this, this gem just makes it easy to do.

I am also concerned with the "memory usage of ImageMagick":http://magick.imagemagick.org/script/architecture.php#cache and didn't want a few bad actors to be able to take down my site just by uploading some big pictures.

h2. Installation

Not only do I have no idea how I would enable some kind of "two gems" approach, but also I don't know what the future of this project is, necessarily.  But it does work, and maybe you'll find it useful.

Install as a rails plugin:

<pre><code>script/plugin install git://github.com/bigfleet/delayed_paperclip.git</code></pre>

Dependencies:
* Paperclip
* resque

h2. Usage

Make sure that you have "Resque":http://github.com/defunkt/resque up and running.  The jobs will be dispatched to the <code>:paperclip</code> queue, so you can correctly dispatch your worker.  Configure resque and your worker exactly as you would otherwise.

In your model:

<pre><code>
  class User < ActiveRecord::Base
    has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
    
    process_in_background :avatar
  end  
</code></pre>

Use your Paperclip attachment just like always in controllers and views.

h2. What if I'm not using images?<commit_msg>README update<commit_after>h1. Delayed::Paperclip

Delayed_paperclip lets you process your "Paperclip":http://github.com/thoughtbot/paperclip attachments in a background task with "delayed_job":http://github.com/tobi/delayed_job or "Resque":http://github.com/defunkt/resque.

h2. Why?

The most common use case for Paperclip is to easily attach image files to ActiveRecord models. Most of the time these image files will have multiple styles and will need to be resized when they are created. This is usually a pretty "slow operation":http://www.jstorimer.com/ruby/2010/01/05/speep-up-your-paperclip-tests.html and should be handled in a background task. 

I'm sure that everyone knows this, this gem just makes it easy to do.

h2. Installation

Install the gem:

<pre><code>sudo gem install delayed_paperclip</code></pre>

Add it to your environment.rb:

<pre><code>config.gem 'delayed_paperclip'</code></pre>

Or, even better, to your Gemfile:

<pre><code>source "http://gemcutter.org"
gem 'delayed_paperclip'
</code></pre>

Or install as a rails plugin:

<pre><code>script/plugin install git://github.com/jstorimer/delayed_paperclip.git</code></pre>

Dependencies:
* Paperclip
* DJ or Resque

h2. Usage

In your model:

<pre><code>
  class User < ActiveRecord::Base
    has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
    
    process_in_background :avatar
  end  
</code></pre>

Use your Paperclip attachment just like always in controllers and views.

h3. Resque
Make sure that you have "Resque":http://github.com/defunkt/resque up and running.  The jobs will be dispatched to the <code>:paperclip</code> queue, so you can correctly dispatch your worker.  Configure resque and your worker exactly as you would otherwise.

h3. DJ

Just make sure that you have DJ up and running.

h2. What if I'm not using images?
{'fraction_non_alphanumeric': 0.09760036917397323, 'fraction_numerical': 0.018458698661744346, 'mean_word_length': 4.5082592121982215, 'pattern_counts': {'":': 15, '<': 37, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5849757', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1327, 'n_words': 507}