Commit cce95085b60147dca5e5d3d3fe77bed193b1578b

Authored by Braulio Bhavamitra
1 parent 3ffe1796

rails4.1: upgrade will_paginate, delayed_job and attachment_fu

Showing 142 changed files with 6 additions and 9253 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 142 files displayed.

1 source "https://rubygems.org" 1 source "https://rubygems.org"
2 -gem 'rails', '~> 4.0' 2 +gem 'rails', '~> 4.1'
3 gem 'minitest', '~> 3.2.0' 3 gem 'minitest', '~> 3.2.0'
4 gem 'fast_gettext', '~> 0.6.8' 4 gem 'fast_gettext', '~> 0.6.8'
5 gem 'acts-as-taggable-on', '~> 3.4.2' 5 gem 'acts-as-taggable-on', '~> 3.4.2'
@@ -7,11 +7,14 @@ gem 'rails_autolink', '~> 1.1.5' @@ -7,11 +7,14 @@ gem 'rails_autolink', '~> 1.1.5'
7 gem 'pg', '~> 0.13.2' 7 gem 'pg', '~> 0.13.2'
8 gem 'rmagick', '~> 2.13.1' 8 gem 'rmagick', '~> 2.13.1'
9 gem 'RedCloth', '~> 4.2.9' 9 gem 'RedCloth', '~> 4.2.9'
10 -gem 'will_paginate', '~> 3.0.3'  
11 gem 'ruby-feedparser', '~> 0.7' 10 gem 'ruby-feedparser', '~> 0.7'
12 gem 'daemons', '~> 1.1.5' 11 gem 'daemons', '~> 1.1.5'
13 gem 'thin', '~> 1.3.1' 12 gem 'thin', '~> 1.3.1'
14 gem 'nokogiri', '~> 1.5.5' 13 gem 'nokogiri', '~> 1.5.5'
  14 +gem 'will_paginate'
  15 +gem 'pothoven-attachment_fu'
  16 +gem 'delayed_job'
  17 +gem 'delayed_job_active_record'
15 gem 'rake', :require => false 18 gem 'rake', :require => false
16 gem 'rest-client', '~> 1.6.7' 19 gem 'rest-client', '~> 1.6.7'
17 gem 'exception_notification', '~> 4.0.1' 20 gem 'exception_notification', '~> 4.0.1'
@@ -30,6 +33,7 @@ gem 'rails-observers' @@ -30,6 +33,7 @@ gem 'rails-observers'
30 gem 'actionpack-page_caching' 33 gem 'actionpack-page_caching'
31 gem 'actionpack-action_caching' 34 gem 'actionpack-action_caching'
32 gem 'activerecord-session_store' 35 gem 'activerecord-session_store'
  36 +gem 'activerecord-deprecated_finders', require: 'active_record/deprecated_finders'
33 37
34 38
35 # FIXME list here all actual dependencies (i.e. the ones in debian/control), 39 # FIXME list here all actual dependencies (i.e. the ones in debian/control),
vendor/plugins/delayed_job/.rspec
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 ---color  
2 ---fail-fast  
3 ---order random  
vendor/plugins/delayed_job/.travis.yml
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -language: ruby  
2 -only:  
3 - - master  
4 -rvm:  
5 - - jruby-19mode  
6 - - rbx-19mode  
7 - - 1.9.2  
8 - - 1.9.3  
9 - - 2.0.0  
10 -env:  
11 - matrix:  
12 - - "RAILS_VERSION=\"~> 3.0.0\""  
13 - - "RAILS_VERSION=\"~> 3.1.0\""  
14 - - "RAILS_VERSION=\"~> 3.2.0\""  
15 - - "RAILS_VERSION=\"~> 4.0.0\""  
16 -matrix:  
17 - exclude:  
18 - - rvm: 1.9.2  
19 - env: "RAILS_VERSION=\"~> 4.0.0\""  
20 - allow_failures:  
21 - - rvm: jruby-19mode  
22 - - rvm: rbx-19mode  
23 \ No newline at end of file 0 \ No newline at end of file
vendor/plugins/delayed_job/CHANGELOG.md
@@ -1,170 +0,0 @@ @@ -1,170 +0,0 @@
1 -4.0.0 - 2013-07-30  
2 -==================  
3 -* Rails 4 compatibility  
4 -* Reverted threaded startup due to daemons incompatibilities  
5 -* Attempt to recover from job reservation errors  
6 -  
7 -4.0.0.beta2 - 2013-05-28  
8 -========================  
9 -* Rails 4 compatibility  
10 -* Threaded startup script for faster multi-worker startup  
11 -* YAML compatibility changes  
12 -* Added jobs:check rake task  
13 -  
14 -4.0.0.beta1 - 2013-03-02  
15 -========================  
16 -* Rails 4 compatibility  
17 -  
18 -3.0.5 - 2013-01-28  
19 -==================  
20 -* Better job timeout error logging  
21 -* psych support for delayed_job_data_mapper deserialization  
22 -* User can configure the worker to raise a SignalException on TERM and/or INT  
23 -* Add the ability to run all available jobs and exit when complete  
24 -  
25 -3.0.4 - 2012-11-09  
26 -==================  
27 -* Allow the app to specify a default queue name  
28 -* Capistrano script now allows user to specify the DJ command, allowing the user to add "bundle exec" if necessary  
29 -* Persisted record check is now more general  
30 -  
31 -3.0.3 - 2012-05-25  
32 -==================  
33 -* Fix a bug where the worker would not respect the exit condition  
34 -* Properly handle sleep delay command line argument  
35 -  
36 -3.0.2 - 2012-04-02  
37 -==================  
38 -* Fix deprecation warnings  
39 -* Raise ArgumentError if attempting to enqueue a performable method on an object that hasn't been persisted yet  
40 -* Allow the number of jobs read at a time to be configured from the command line using --read-ahead  
41 -* Allow custom logger to be configured through Delayed::Worker.logger  
42 -* Various documentation improvements  
43 -  
44 -3.0.1 - 2012-01-24  
45 -==================  
46 -* Added RecordNotFound message to deserialization error  
47 -* Direct JRuby's yecht parser to syck extensions  
48 -* Updated psych extensions for better compatibility with ruby 1.9.2  
49 -* Updated syck extension for increased compatibility with class methods  
50 -* Test grooming  
51 -  
52 -3.0.0 - 2011-12-30  
53 -==================  
54 -* New: Named queues  
55 -* New: Job/Worker lifecycle callbacks  
56 -* Change: daemons is no longer a runtime dependency  
57 -* Change: Active Record backend support is provided by a separate gem  
58 -* Change: Enqueue hook is called before jobs are saved so that they may be modified  
59 -* Fix problem deserializing models that use a custom primary key column  
60 -* Fix deserializing AR models when the object isn't in the default scope  
61 -* Fix hooks not getting called when delay_jobs is false  
62 -  
63 -2.1.4 - 2011-02-11  
64 -==================  
65 -* Working around issues when psych is loaded, fixes issues with bundler 1.0.10 and Rails 3.0.4  
66 -* Added -p/--prefix option to help differentiate multiple delayed job workers on the same host.  
67 -  
68 -2.1.3 - 2011-01-20  
69 -==================  
70 -* Revert worker contention fix due to regressions  
71 -* Added Delayed::Worker.delay_jobs flag to support running jobs immediately  
72 -  
73 -2.1.2 - 2010-12-01  
74 -==================  
75 -* Remove contention between multiple workers by performing an update to lock a job before fetching it  
76 -* Job payloads may implement #max_attempts to control how many times it should be retried  
77 -* Fix for loading ActionMailer extension  
78 -* Added 'delayed_job_server_role' Capistrano variable to allow delayed_job to run on its own worker server  
79 - set :delayed_job_server_role, :worker  
80 -* Fix `rake jobs:work` so it outputs to the console  
81 -  
82 -2.1.1 - 2010-11-14  
83 -==================  
84 -* Fix issue with worker name not getting properly set when locking a job  
85 -* Fixes for YAML serialization  
86 -  
87 -2.1.0 - 2010-11-14  
88 -==================  
89 -* Added enqueue, before, after, success, error, and failure. See the README  
90 -* Remove Merb support  
91 -* Remove all non Active Record backends into separate gems. See https://github.com/collectiveidea/delayed_job/wiki/Backends  
92 -* remove rails 2 support. delayed_job 2.1 will only support Rails 3  
93 -* New pure-YAML serialization  
94 -* Added Rails 3 railtie and generator  
95 -* Changed @@sleep_delay to self.class.sleep_delay to be consistent with other class variable usage  
96 -* Added --sleep-delay command line option  
97 -  
98 -2.0.8 - Unreleased  
99 -==================  
100 -* Backport fix for deserialization errors that bring down the daemon  
101 -  
102 -2.0.7 - 2011-02-10  
103 -==================  
104 -* Fixed missing generators and recipes for Rails 2.x  
105 -  
106 -2.0.6 - 2011-01-20  
107 -==================  
108 -* Revert worker contention fix due to regressions  
109 -  
110 -2.0.5 - 2010-12-01  
111 -==================  
112 -* Added #reschedule_at hook on payload to determine when the job should be rescheduled [backported from 2.1]  
113 -* Added --sleep-delay command line option [backported from 2.1]  
114 -* Added 'delayed_job_server_role' Capistrano variable to allow delayed_job to run on its own worker server  
115 - set :delayed_job_server_role, :worker  
116 -* Changed AR backend to reserve jobs using an UPDATE query to reduce worker contention [backported from 2.1]  
117 -  
118 -2.0.4 - 2010-11-14  
119 -==================  
120 -* Fix issue where dirty tracking prevented job from being properly unlocked  
121 -* Add delayed_job_args variable for Capistrano recipe to allow configuration of started workers (e.g. "-n 2 --max-priority 10")  
122 -* Added options to handle_asynchronously  
123 -* Added Delayed::Worker.default_priority  
124 -* Allow private methods to be delayed  
125 -* Fixes for Ruby 1.9  
126 -* Added -m command line option to start a monitor process  
127 -* normalize logging in worker  
128 -* Deprecate #send_later and #send_at in favor of new #delay method  
129 -* Added @#delay@ to Object that allows you to delay any method and pass options:  
130 - options = {:priority => 19, :run_at => 5.minutes.from_now}  
131 - UserMailer.delay(options).deliver_confirmation(@user)  
132 -  
133 -2.0.3 - 2010-04-16  
134 -==================  
135 -* Fix initialization for Rails 2.x  
136 -  
137 -2.0.2 - 2010-04-08  
138 -==================  
139 -* Fixes to Mongo Mapper backend [ "14be7a24":http://github.com/collectiveidea/delayed_job/commit/14be7a24, "dafd5f46":http://github.com/collectiveidea/delayed_job/commit/dafd5f46, "54d40913":http://github.com/collectiveidea/delayed_job/commit/54d40913 ]  
140 -* DataMapper backend performance improvements [ "93833cce":http://github.com/collectiveidea/delayed_job/commit/93833cce, "e9b1573e":http://github.com/collectiveidea/delayed_job/commit/e9b1573e, "37a16d11":http://github.com/collectiveidea/delayed_job/commit/37a16d11, "803f2bfa":http://github.com/collectiveidea/delayed_job/commit/803f2bfa ]  
141 -* Fixed Delayed::Command to create tmp/pids directory [ "8ec8ca41":http://github.com/collectiveidea/delayed_job/commit/8ec8ca41 ]  
142 -* Railtie to perform Rails 3 initialization [ "3e0fc41f":http://github.com/collectiveidea/delayed_job/commit/3e0fc41f ]  
143 -* Added on_permanent_failure hook [ "d2f14cd6":http://github.com/collectiveidea/delayed_job/commit/d2f14cd6 ]  
144 -  
145 -2.0.1 - 2010-04-03  
146 -==================  
147 -* Bug fix for using ActiveRecord backend with daemon [martinbtt]  
148 -  
149 -2.0.0 - 2010-04-03  
150 -==================  
151 -* Multiple backend support (See README for more details)  
152 -* Added MongoMapper backend [zbelzer, moneypools]  
153 -* Added DataMapper backend [lpetre]  
154 -* Reverse priority so the jobs table can be indexed. Lower numbers have higher priority. The default priority is 0, so increase it for jobs that are not important.  
155 -* Move most of the heavy lifting from Job to Worker (#work_off, #reschedule, #run, #min_priority, #max_priority, #max_run_time, #max_attempts, #worker_name) [albus522]  
156 -* Remove EvaledJob. Implement your own if you need this functionality.  
157 -* Only use Time.zone if it is set. Closes #20  
158 -* Fix for last_error recording when destroy_failed_jobs = false, max_attempts = 1  
159 -* Implemented worker name_prefix to maintain dynamic nature of pid detection  
160 -* Some Rails 3 compatibility fixes [fredwu]  
161 -  
162 -1.8.5 - 2010-03-15  
163 -==================  
164 -* Set auto_flushing=true on Rails logger to fix logging in production  
165 -* Fix error message when trying to send_later on a method that doesn't exist  
166 -* Don't use rails_env in capistrano if it's not set. closes #22  
167 -* Delayed job should append to delayed_job.log not overwrite  
168 -* Version bump to 1.8.5  
169 -* fixing Time.now to be Time.zone.now if set to honor the app set local TimeZone  
170 -* Replaced @Worker::SLEEP@, @Job::MAX_ATTEMPTS@, and @Job::MAX_RUN_TIME@ with class methods that can be overridden.  
vendor/plugins/delayed_job/CONTRIBUTING.md
@@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
1 -How to contribute  
2 -=================  
3 -  
4 -If you find what looks like a bug:  
5 -  
6 -* Search the "mailing list":http://groups.google.com/group/delayed_job to see  
7 - if anyone else had the same issue.  
8 -* Check the "GitHub issue tracker":http://github.com/collectiveidea/delayed_job/issues/  
9 - to see if anyone else has reported issue.  
10 -* Make sure you are using the latest version of delayed_job  
11 - ![Gem Version](https://badge.fury.io/rb/delayed_job.png)  
12 -* Make sure you are using the latest backend gem for delayed_job  
13 - * Active Record ![Gem Version](https://badge.fury.io/rb/delayed_job_active_record.png)  
14 - * Mongoid ![Gem Version](https://badge.fury.io/rb/delayed_job_mongoid.png)  
15 -* If you are still having an issue, create an issue including:  
16 - * Ruby version  
17 - * Gemfile.lock contents or at least major gem versions, such as Rails version  
18 - * Steps to reproduce the issue  
19 - * Full backtrace for any errors encountered  
20 -  
21 -If you want to contribute an enhancement or a fix:  
22 -  
23 -* Fork the project on GitHub.  
24 -* Make your changes with tests.  
25 -* Commit the changes without making changes to the Rakefile or any other files  
26 - that aren't related to your enhancement or fix.  
27 -* Send a pull request.  
vendor/plugins/delayed_job/Gemfile
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -platforms :ruby do  
6 - gem 'sqlite3'  
7 -end  
8 -  
9 -platforms :jruby do  
10 - gem 'jruby-openssl'  
11 - gem 'activerecord-jdbcsqlite3-adapter'  
12 -end  
13 -  
14 -group :test do  
15 - gem 'activerecord', (ENV['RAILS_VERSION'] || ['>= 3.0', '< 4.1'])  
16 - gem 'actionmailer', (ENV['RAILS_VERSION'] || ['>= 3.0', '< 4.1'])  
17 - gem 'coveralls', :require => false  
18 - gem 'rspec', '>= 2.11'  
19 - gem 'simplecov', :require => false  
20 -end  
21 -  
22 -gemspec  
vendor/plugins/delayed_job/LICENSE.md
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -Copyright (c) 2005 Tobias Lütke  
2 -  
3 -Permission is hereby granted, free of charge, to any person obtaining  
4 -a copy of this software and associated documentation files (the  
5 -"Software"), to deal in the Software without restriction, including  
6 -without limitation the rights to use, copy, modify, merge, publish,  
7 -distribute, sublicense, and/or sell copies of the Software, and to  
8 -permit persons to whom the Software is furnished to do so, subject to  
9 -the following conditions:  
10 -  
11 -The above copyright notice and this permission notice shall be  
12 -included in all copies or substantial portions of the Software.  
13 -  
14 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  
15 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
16 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND  
17 -NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE  
18 -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION  
19 -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
20 -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
vendor/plugins/delayed_job/README.md
@@ -1,346 +0,0 @@ @@ -1,346 +0,0 @@
1 -Delayed::Job  
2 -============  
3 -[![Gem Version](https://badge.fury.io/rb/delayed_job.png)][gem]  
4 -[![Build Status](https://secure.travis-ci.org/collectiveidea/delayed_job.png?branch=master)][travis]  
5 -[![Dependency Status](https://gemnasium.com/collectiveidea/delayed_job.png?travis)][gemnasium]  
6 -[![Code Climate](https://codeclimate.com/github/collectiveidea/delayed_job.png)][codeclimate]  
7 -[![Coverage Status](https://coveralls.io/repos/collectiveidea/delayed_job/badge.png?branch=master)][coveralls]  
8 -  
9 -[gem]: https://rubygems.org/gems/delayed_job  
10 -[travis]: http://travis-ci.org/collectiveidea/delayed_job  
11 -[gemnasium]: https://gemnasium.com/collectiveidea/delayed_job  
12 -[codeclimate]: https://codeclimate.com/github/collectiveidea/delayed_job  
13 -[coveralls]: https://coveralls.io/r/collectiveidea/delayed_job  
14 -  
15 -Delayed::Job (or DJ) encapsulates the common pattern of asynchronously executing  
16 -longer tasks in the background.  
17 -  
18 -It is a direct extraction from Shopify where the job table is responsible for a  
19 -multitude of core tasks. Amongst those tasks are:  
20 -  
21 -* sending massive newsletters  
22 -* image resizing  
23 -* http downloads  
24 -* updating smart collections  
25 -* updating solr, our search server, after product changes  
26 -* batch imports  
27 -* spam checks  
28 -  
29 -[Follow us on Twitter][twitter] to get updates and notices about new releases.  
30 -  
31 -[twitter]: https://twitter.com/delayedjob  
32 -  
33 -Installation  
34 -============  
35 -delayed_job 3.0.0 only supports Rails 3.0+. See the [2.0  
36 -branch](https://github.com/collectiveidea/delayed_job/tree/v2.0) for Rails 2.  
37 -  
38 -delayed_job supports multiple backends for storing the job queue. [See the wiki  
39 -for other backends](http://wiki.github.com/collectiveidea/delayed_job/backends).  
40 -  
41 -If you plan to use delayed_job with Active Record, add `delayed_job_active_record` to your `Gemfile`.  
42 -  
43 -```ruby  
44 -gem 'delayed_job_active_record'  
45 -```  
46 -  
47 -If you plan to use delayed_job with Mongoid, add `delayed_job_mongoid` to your `Gemfile`.  
48 -  
49 -```ruby  
50 -gem 'delayed_job_mongoid'  
51 -```  
52 -  
53 -Run `bundle install` to install the backend and delayed_job gems.  
54 -  
55 -The Active Record backend requires a jobs table. You can create that table by  
56 -running the following command:  
57 -  
58 - rails generate delayed_job:active_record  
59 - rake db:migrate  
60 -  
61 -Rails 4  
62 -=======  
63 -If you are using the protected_attributes gem, it must appear before delayed_job in your gemfile.  
64 -  
65 -Upgrading from 2.x to 3.0.0 on Active Record  
66 -============================================  
67 -Delayed Job 3.0.0 introduces a new column to the delayed_jobs table.  
68 -  
69 -If you're upgrading from Delayed Job 2.x, run the upgrade generator to create a migration to add the column.  
70 -  
71 - rails generate delayed_job:upgrade  
72 - rake db:migrate  
73 -  
74 -Queuing Jobs  
75 -============  
76 -Call `.delay.method(params)` on any object and it will be processed in the background.  
77 -  
78 -```ruby  
79 -# without delayed_job  
80 -@user.activate!(@device)  
81 -  
82 -# with delayed_job  
83 -@user.delay.activate!(@device)  
84 -```  
85 -  
86 -If a method should always be run in the background, you can call  
87 -`#handle_asynchronously` after the method declaration:  
88 -  
89 -```ruby  
90 -class Device  
91 - def deliver  
92 - # long running method  
93 - end  
94 - handle_asynchronously :deliver  
95 -end  
96 -  
97 -device = Device.new  
98 -device.deliver  
99 -```  
100 -  
101 -handle_asynchronously can take as options anything you can pass to delay. In  
102 -addition, the values can be Proc objects allowing call time evaluation of the  
103 -value. For some examples:  
104 -  
105 -```ruby  
106 -class LongTasks  
107 - def send_mailer  
108 - # Some other code  
109 - end  
110 - handle_asynchronously :send_mailer, :priority => 20  
111 -  
112 - def in_the_future  
113 - # Some other code  
114 - end  
115 - # 5.minutes.from_now will be evaluated when in_the_future is called  
116 - handle_asynchronously :in_the_future, :run_at => Proc.new { 5.minutes.from_now }  
117 -  
118 - def self.when_to_run  
119 - 2.hours.from_now  
120 - end  
121 -  
122 - def call_a_class_method  
123 - # Some other code  
124 - end  
125 - handle_asynchronously :call_a_class_method, :run_at => Proc.new { when_to_run }  
126 -  
127 - attr_reader :how_important  
128 -  
129 - def call_an_instance_method  
130 - # Some other code  
131 - end  
132 - handle_asynchronously :call_an_instance_method, :priority => Proc.new {|i| i.how_important }  
133 -end  
134 -```  
135 -  
136 -If you ever want to call a `handle_asynchronously`'d method without Delayed Job, for instance while debugging something at the console, just add `_without_delay` to the method name. For instance, if your original method was `foo`, then call `foo_without_delay`.  
137 -  
138 -Rails 3 Mailers  
139 -===============  
140 -Due to how mailers are implemented in Rails 3, we had to do a little work around to get delayed_job to work.  
141 -  
142 -```ruby  
143 -# without delayed_job  
144 -Notifier.signup(@user).deliver  
145 -  
146 -# with delayed_job  
147 -Notifier.delay.signup(@user)  
148 -```  
149 -  
150 -Remove the `.deliver` method to make it work. It's not ideal, but it's the best  
151 -we could do for now.  
152 -  
153 -Named Queues  
154 -============  
155 -DJ 3 introduces Resque-style named queues while still retaining DJ-style  
156 -priority. The goal is to provide a system for grouping tasks to be worked by  
157 -separate pools of workers, which may be scaled and controlled individually.  
158 -  
159 -Jobs can be assigned to a queue by setting the `queue` option:  
160 -  
161 -```ruby  
162 -object.delay(:queue => 'tracking').method  
163 -  
164 -Delayed::Job.enqueue job, :queue => 'tracking'  
165 -  
166 -handle_asynchronously :tweet_later, :queue => 'tweets'  
167 -```  
168 -  
169 -Running Jobs  
170 -============  
171 -`script/delayed_job` can be used to manage a background process which will  
172 -start working off jobs.  
173 -  
174 -To do so, add `gem "daemons"` to your `Gemfile` and make sure you've run `rails  
175 -generate delayed_job`.  
176 -  
177 -You can then do the following:  
178 -  
179 - RAILS_ENV=production script/delayed_job start  
180 - RAILS_ENV=production script/delayed_job stop  
181 -  
182 - # Runs two workers in separate processes.  
183 - RAILS_ENV=production script/delayed_job -n 2 start  
184 - RAILS_ENV=production script/delayed_job stop  
185 -  
186 - # Set the --queue or --queues option to work from a particular queue.  
187 - RAILS_ENV=production script/delayed_job --queue=tracking start  
188 - RAILS_ENV=production script/delayed_job --queues=mailers,tasks start  
189 -  
190 - # Runs all available jobs and then exits  
191 - RAILS_ENV=production script/delayed_job start --exit-on-complete  
192 - # or to run in the foreground  
193 - RAILS_ENV=production script/delayed_job run --exit-on-complete  
194 -  
195 -**Rails 4:** *replace script/delayed_job with bin/delayed_job*  
196 -  
197 -Workers can be running on any computer, as long as they have access to the  
198 -database and their clock is in sync. Keep in mind that each worker will check  
199 -the database at least every 5 seconds.  
200 -  
201 -You can also invoke `rake jobs:work` which will start working off jobs. You can  
202 -cancel the rake task with `CTRL-C`.  
203 -  
204 -If you want to just run all available jobs and exit you can use `rake jobs:workoff`  
205 -  
206 -Work off queues by setting the `QUEUE` or `QUEUES` environment variable.  
207 -  
208 - QUEUE=tracking rake jobs:work  
209 - QUEUES=mailers,tasks rake jobs:work  
210 -  
211 -Restarting delayed_job  
212 -======================  
213 -  
214 -The following syntax will restart delayed jobs:  
215 -  
216 - RAILS_ENV=production script/delayed_job restart  
217 -  
218 -To restart multiple delayed_job workers:  
219 -  
220 - RAILS_ENV=production script/delayed_job -n2 restart  
221 -  
222 -**Rails 4:** *replace script/delayed_job with bin/delayed_job*  
223 -  
224 -  
225 -  
226 -Custom Jobs  
227 -===========  
228 -Jobs are simple ruby objects with a method called perform. Any object which responds to perform can be stuffed into the jobs table. Job objects are serialized to yaml so that they can later be resurrected by the job runner.  
229 -  
230 -```ruby  
231 -class NewsletterJob < Struct.new(:text, :emails)  
232 - def perform  
233 - emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }  
234 - end  
235 -end  
236 -  
237 -Delayed::Job.enqueue NewsletterJob.new('lorem ipsum...', Customers.find(:all).collect(&:email))  
238 -```  
239 -To set a per-job max attempts that overrides the Delayed::Worker.max_attempts you can define a max_attempts method on the job  
240 -```ruby  
241 -class NewsletterJob < Struct.new(:text, :emails)  
242 - def perform  
243 - emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }  
244 - end  
245 -  
246 - def max_attempts  
247 - return 3  
248 - end  
249 -end  
250 -````  
251 -  
252 -  
253 -Hooks  
254 -=====  
255 -You can define hooks on your job that will be called at different stages in the process:  
256 -  
257 -```ruby  
258 -class ParanoidNewsletterJob < NewsletterJob  
259 - def enqueue(job)  
260 - record_stat 'newsletter_job/enqueue'  
261 - end  
262 -  
263 - def perform  
264 - emails.each { |e| NewsletterMailer.deliver_text_to_email(text, e) }  
265 - end  
266 -  
267 - def before(job)  
268 - record_stat 'newsletter_job/start'  
269 - end  
270 -  
271 - def after(job)  
272 - record_stat 'newsletter_job/after'  
273 - end  
274 -  
275 - def success(job)  
276 - record_stat 'newsletter_job/success'  
277 - end  
278 -  
279 - def error(job, exception)  
280 - Airbrake.notify(exception)  
281 - end  
282 -  
283 - def failure(job)  
284 - page_sysadmin_in_the_middle_of_the_night  
285 - end  
286 -end  
287 -```  
288 -  
289 -Gory Details  
290 -============  
291 -The library revolves around a delayed_jobs table which looks as follows:  
292 -  
293 -```ruby  
294 -create_table :delayed_jobs, :force => true do |table|  
295 - table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue  
296 - table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.  
297 - table.text :handler # YAML-encoded string of the object that will do work  
298 - table.text :last_error # reason for last failure (See Note below)  
299 - table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.  
300 - table.datetime :locked_at # Set when a client is working on this object  
301 - table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)  
302 - table.string :locked_by # Who is working on this object (if locked)  
303 - table.string :queue # The name of the queue this job is in  
304 - table.timestamps  
305 -end  
306 -```  
307 -  
308 -On failure, the job is scheduled again in 5 seconds + N ** 4, where N is the number of retries.  
309 -  
310 -The default Worker.max_attempts is 25. After this, the job either deleted (default), or left in the database with "failed_at" set.  
311 -With the default of 25 attempts, the last retry will be 20 days later, with the last interval being almost 100 hours.  
312 -  
313 -The default Worker.max_run_time is 4.hours. If your job takes longer than that, another computer could pick it up. It's up to you to  
314 -make sure your job doesn't exceed this time. You should set this to the longest time you think the job could take.  
315 -  
316 -By default, it will delete failed jobs (and it always deletes successful jobs). If you want to keep failed jobs, set  
317 -Delayed::Worker.destroy_failed_jobs = false. The failed jobs will be marked with non-null failed_at.  
318 -  
319 -By default all jobs are scheduled with priority = 0, which is top priority. You can change this by setting Delayed::Worker.default_priority to something else. Lower numbers have higher priority.  
320 -  
321 -The default behavior is to read 5 jobs from the queue when finding an available job. You can configure this by setting Delayed::Worker.read_ahead.  
322 -  
323 -By default all jobs will be queued without a named queue. A default named queue can be specified by using Delayed::Worker.default_queue_name.  
324 -  
325 -It is possible to disable delayed jobs for testing purposes. Set Delayed::Worker.delay_jobs = false to execute all jobs realtime.  
326 -  
327 -Here is an example of changing job parameters in Rails:  
328 -  
329 -```ruby  
330 -# config/initializers/delayed_job_config.rb  
331 -Delayed::Worker.destroy_failed_jobs = false  
332 -Delayed::Worker.sleep_delay = 60  
333 -Delayed::Worker.max_attempts = 3  
334 -Delayed::Worker.max_run_time = 5.minutes  
335 -Delayed::Worker.read_ahead = 10  
336 -Delayed::Worker.default_queue_name = 'default'  
337 -Delayed::Worker.delay_jobs = !Rails.env.test?  
338 -```  
339 -  
340 -Cleaning up  
341 -===========  
342 -You can invoke `rake jobs:clear` to delete all jobs in the queue.  
343 -  
344 -Mailing List  
345 -============  
346 -Join us on the [mailing list](http://groups.google.com/group/delayed_job)  
vendor/plugins/delayed_job/Rakefile
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -# -*- encoding: utf-8 -*-  
2 -require 'bundler/setup'  
3 -Bundler::GemHelper.install_tasks  
4 -  
5 -require 'rspec/core/rake_task'  
6 -desc 'Run the specs'  
7 -RSpec::Core::RakeTask.new do |r|  
8 - r.verbose = false  
9 -end  
10 -  
11 -task :default => :spec  
vendor/plugins/delayed_job/benchmarks.rb
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -require 'spec/helper'  
2 -require 'logger'  
3 -require 'benchmark'  
4 -  
5 -# Delayed::Worker.logger = Logger.new('/dev/null')  
6 -  
7 -Benchmark.bm(10) do |x|  
8 - Delayed::Job.delete_all  
9 - n = 10000  
10 - n.times { "foo".delay.length }  
11 -  
12 - x.report { Delayed::Worker.new(:quiet => true).work_off(n) }  
13 -end  
vendor/plugins/delayed_job/contrib/delayed_job.monitrc
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -# an example Monit configuration file for delayed_job  
2 -# See: http://stackoverflow.com/questions/1226302/how-to-monitor-delayedjob-with-monit/1285611  
3 -#  
4 -# To use:  
5 -# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc  
6 -# 2. replace {app_name} as appropriate  
7 -# 3. add this to your /etc/monit/monitrc  
8 -#  
9 -# include /var/www/apps/{app_name}/shared/delayed_job.monitrc  
10 -  
11 -check process delayed_job  
12 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid  
13 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start"  
14 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop"  
vendor/plugins/delayed_job/contrib/delayed_job_multiple.monitrc
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -# an example Monit configuration file for delayed_job running multiple processes  
2 -#  
3 -# To use:  
4 -# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc  
5 -# 2. replace {app_name} as appropriate  
6 -# you might also need to change the program strings to  
7 -# "/bin/su - {username} -c '/usr/bin/env ...'"  
8 -# to load your shell environment.  
9 -#  
10 -# 3. add this to your /etc/monit/monitrc  
11 -#  
12 -# include /var/www/apps/{app_name}/shared/delayed_job.monitrc  
13 -#  
14 -# The processes are grouped so that monit can act on them as a whole, e.g.  
15 -#  
16 -# monit -g delayed_job restart  
17 -  
18 -check process delayed_job_0  
19 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.0.pid  
20 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 0"  
21 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 0"  
22 - group delayed_job  
23 -  
24 -check process delayed_job_1  
25 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.1.pid  
26 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 1"  
27 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 1"  
28 - group delayed_job  
29 -  
30 -check process delayed_job_2  
31 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.2.pid  
32 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 2"  
33 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 2"  
34 - group delayed_job  
vendor/plugins/delayed_job/contrib/delayed_job_rails_4.monitrc
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -# an example Monit configuration file for delayed_job  
2 -# See: http://stackoverflow.com/questions/1226302/how-to-monitor-delayedjob-with-monit/1285611  
3 -#  
4 -# To use:  
5 -# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc  
6 -# 2. replace {app_name} as appropriate  
7 -# 3. add this to your /etc/monit/monitrc  
8 -#  
9 -# include /var/www/apps/{app_name}/shared/delayed_job.monitrc  
10 -  
11 -check process delayed_job  
12 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid  
13 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job start"  
14 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job stop"  
vendor/plugins/delayed_job/contrib/delayed_job_rails_4_multiple.monitrc
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -# an example Monit configuration file for delayed_job running multiple processes  
2 -#  
3 -# To use:  
4 -# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc  
5 -# 2. replace {app_name} as appropriate  
6 -# you might also need to change the program strings to  
7 -# "/bin/su - {username} -c '/usr/bin/env ...'"  
8 -# to load your shell environment.  
9 -#  
10 -# 3. add this to your /etc/monit/monitrc  
11 -#  
12 -# include /var/www/apps/{app_name}/shared/delayed_job.monitrc  
13 -#  
14 -# The processes are grouped so that monit can act on them as a whole, e.g.  
15 -#  
16 -# monit -g delayed_job restart  
17 -  
18 -check process delayed_job_0  
19 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.0.pid  
20 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job start -i 0"  
21 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job stop -i 0"  
22 - group delayed_job  
23 -  
24 -check process delayed_job_1  
25 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.1.pid  
26 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job start -i 1"  
27 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job stop -i 1"  
28 - group delayed_job  
29 -  
30 -check process delayed_job_2  
31 - with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.2.pid  
32 - start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job start -i 2"  
33 - stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/bin/delayed_job stop -i 2"  
34 - group delayed_job  
vendor/plugins/delayed_job/delayed_job.gemspec
@@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
1 -# -*- encoding: utf-8 -*-  
2 -  
3 -Gem::Specification.new do |spec|  
4 - spec.add_dependency 'activesupport', ['>= 3.0', '< 4.1']  
5 - spec.authors = ["Brandon Keepers", "Brian Ryckbost", "Chris Gaffney", "David Genord II", "Erik Michaels-Ober", "Matt Griffin", "Steve Richert", "Tobias Lütke"]  
6 - spec.description = "Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks."  
7 - spec.email = ['brian@collectiveidea.com']  
8 - spec.files = %w(CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md Rakefile delayed_job.gemspec)  
9 - spec.files += Dir.glob('{contrib,lib,recipes,spec}/**/*')  
10 - spec.homepage = 'http://github.com/collectiveidea/delayed_job'  
11 - spec.licenses = ['MIT']  
12 - spec.name = 'delayed_job'  
13 - spec.require_paths = ['lib']  
14 - spec.summary = 'Database-backed asynchronous priority queue system -- Extracted from Shopify'  
15 - spec.test_files = Dir.glob('spec/**/*')  
16 - spec.version = '4.0.0'  
17 -end  
vendor/plugins/delayed_job/lib/delayed/backend/base.rb
@@ -1,156 +0,0 @@ @@ -1,156 +0,0 @@
1 -module Delayed  
2 - module Backend  
3 - module Base  
4 - def self.included(base)  
5 - base.extend ClassMethods  
6 - end  
7 -  
8 - module ClassMethods  
9 - # Add a job to the queue  
10 - def enqueue(*args)  
11 - options = {  
12 - :priority => Delayed::Worker.default_priority,  
13 - :queue => Delayed::Worker.default_queue_name  
14 - }.merge!(args.extract_options!)  
15 -  
16 - options[:payload_object] ||= args.shift  
17 -  
18 - if args.size > 0  
19 - warn "[DEPRECATION] Passing multiple arguments to `#enqueue` is deprecated. Pass a hash with :priority and :run_at."  
20 - options[:priority] = args.first || options[:priority]  
21 - options[:run_at] = args[1]  
22 - end  
23 -  
24 - unless options[:payload_object].respond_to?(:perform)  
25 - raise ArgumentError, 'Cannot enqueue items which do not respond to perform'  
26 - end  
27 -  
28 - if Delayed::Worker.delay_jobs  
29 - self.new(options).tap do |job|  
30 - Delayed::Worker.lifecycle.run_callbacks(:enqueue, job) do  
31 - job.hook(:enqueue)  
32 - job.save  
33 - end  
34 - end  
35 - else  
36 - Delayed::Job.new(:payload_object => options[:payload_object]).tap do |job|  
37 - job.invoke_job  
38 - end  
39 - end  
40 - end  
41 -  
42 - def reserve(worker, max_run_time = Worker.max_run_time)  
43 - # We get up to 5 jobs from the db. In case we cannot get exclusive access to a job we try the next.  
44 - # this leads to a more even distribution of jobs across the worker processes  
45 - find_available(worker.name, worker.read_ahead, max_run_time).detect do |job|  
46 - job.lock_exclusively!(max_run_time, worker.name)  
47 - end  
48 - end  
49 -  
50 - # Allow the backend to attempt recovery from reserve errors  
51 - def recover_from(error)  
52 - end  
53 -  
54 - # Hook method that is called before a new worker is forked  
55 - def before_fork  
56 - end  
57 -  
58 - # Hook method that is called after a new worker is forked  
59 - def after_fork  
60 - end  
61 -  
62 - def work_off(num = 100)  
63 - warn "[DEPRECATION] `Delayed::Job.work_off` is deprecated. Use `Delayed::Worker.new.work_off instead."  
64 - Delayed::Worker.new.work_off(num)  
65 - end  
66 - end  
67 -  
68 - def failed?  
69 - !!failed_at  
70 - end  
71 - alias_method :failed, :failed?  
72 -  
73 - ParseObjectFromYaml = /\!ruby\/\w+\:([^\s]+)/  
74 -  
75 - def name  
76 - obj = payload_object  
77 - @name ||= obj.respond_to?(:display_name) ? obj.display_name : obj.class.name  
78 - rescue DeserializationError  
79 - ParseObjectFromYaml.match(handler)[1]  
80 - end  
81 -  
82 - def payload_object=(object)  
83 - @payload_object = object  
84 - self.handler = object.to_yaml  
85 - end  
86 -  
87 - def payload_object  
88 - if YAML.respond_to?(:unsafe_load)  
89 - #See https://github.com/dtao/safe_yaml  
90 - #When the method is there, we need to load our YAML like this...  
91 - @payload_object ||= YAML.load(self.handler, :safe => false)  
92 - else  
93 - @payload_object ||= YAML.load(self.handler)  
94 - end  
95 - rescue TypeError, LoadError, NameError, ArgumentError => e  
96 - raise DeserializationError,  
97 - "Job failed to load: #{e.message}. Handler: #{handler.inspect}"  
98 - end  
99 -  
100 - def invoke_job  
101 - Delayed::Worker.lifecycle.run_callbacks(:invoke_job, self) do  
102 - begin  
103 - hook :before  
104 - payload_object.perform  
105 - hook :success  
106 - rescue Exception => e  
107 - hook :error, e  
108 - raise e  
109 - ensure  
110 - hook :after  
111 - end  
112 - end  
113 - end  
114 -  
115 - # Unlock this job (note: not saved to DB)  
116 - def unlock  
117 - self.locked_at = nil  
118 - self.locked_by = nil  
119 - end  
120 -  
121 - def hook(name, *args)  
122 - if payload_object.respond_to?(name)  
123 - method = payload_object.method(name)  
124 - method.arity == 0 ? method.call : method.call(self, *args)  
125 - end  
126 - rescue DeserializationError  
127 - # do nothing  
128 - end  
129 -  
130 - def reschedule_at  
131 - payload_object.respond_to?(:reschedule_at) ?  
132 - payload_object.reschedule_at(self.class.db_time_now, attempts) :  
133 - self.class.db_time_now + (attempts ** 4) + 5  
134 - end  
135 -  
136 - def max_attempts  
137 - payload_object.max_attempts if payload_object.respond_to?(:max_attempts)  
138 - end  
139 -  
140 - def fail!  
141 - update_attributes(:failed_at => self.class.db_time_now)  
142 - end  
143 -  
144 - protected  
145 -  
146 - def set_default_run_at  
147 - self.run_at ||= self.class.db_time_now  
148 - end  
149 -  
150 - # Call during reload operation to clear out internal state  
151 - def reset  
152 - @payload_object = nil  
153 - end  
154 - end  
155 - end  
156 -end  
vendor/plugins/delayed_job/lib/delayed/backend/shared_spec.rb
@@ -1,594 +0,0 @@ @@ -1,594 +0,0 @@
1 -require File.expand_path('../../../../spec/sample_jobs', __FILE__)  
2 -  
3 -require 'active_support/core_ext'  
4 -  
5 -shared_examples_for "a delayed_job backend" do  
6 - let(:worker) { Delayed::Worker.new }  
7 -  
8 - def create_job(opts = {})  
9 - described_class.create(opts.merge(:payload_object => SimpleJob.new))  
10 - end  
11 -  
12 - before do  
13 - Delayed::Worker.max_priority = nil  
14 - Delayed::Worker.min_priority = nil  
15 - Delayed::Worker.default_priority = 99  
16 - Delayed::Worker.delay_jobs = true  
17 - SimpleJob.runs = 0  
18 - described_class.delete_all  
19 - end  
20 -  
21 - after do  
22 - Delayed::Worker.reset  
23 - end  
24 -  
25 - it "sets run_at automatically if not set" do  
26 - expect(described_class.create(:payload_object => ErrorJob.new ).run_at).not_to be_nil  
27 - end  
28 -  
29 - it "does not set run_at automatically if already set" do  
30 - later = described_class.db_time_now + 5.minutes  
31 - job = described_class.create(:payload_object => ErrorJob.new, :run_at => later)  
32 - expect(job.run_at).to be_within(1).of(later)  
33 - end  
34 -  
35 - describe "#reload" do  
36 - it "reloads the payload" do  
37 - job = described_class.enqueue :payload_object => SimpleJob.new  
38 - expect(job.payload_object.object_id).not_to eq(job.reload.payload_object.object_id)  
39 - end  
40 - end  
41 -  
42 - describe "enqueue" do  
43 - context "with a hash" do  
44 - it "raises ArgumentError when handler doesn't respond_to :perform" do  
45 - expect{described_class.enqueue(:payload_object => Object.new)}.to raise_error(ArgumentError)  
46 - end  
47 -  
48 - it "is able to set priority" do  
49 - job = described_class.enqueue :payload_object => SimpleJob.new, :priority => 5  
50 - expect(job.priority).to eq(5)  
51 - end  
52 -  
53 - it "uses default priority" do  
54 - job = described_class.enqueue :payload_object => SimpleJob.new  
55 - expect(job.priority).to eq(99)  
56 - end  
57 -  
58 - it "is able to set run_at" do  
59 - later = described_class.db_time_now + 5.minutes  
60 - job = described_class.enqueue :payload_object => SimpleJob.new, :run_at => later  
61 - expect(job.run_at).to be_within(1).of(later)  
62 - end  
63 -  
64 - it "is able to set queue" do  
65 - job = described_class.enqueue :payload_object => SimpleJob.new, :queue => 'tracking'  
66 - expect(job.queue).to eq('tracking')  
67 - end  
68 - end  
69 -  
70 - context "with multiple arguments" do  
71 - it "raises ArgumentError when handler doesn't respond_to :perform" do  
72 - expect{described_class.enqueue(Object.new)}.to raise_error(ArgumentError)  
73 - end  
74 -  
75 - it "increases count after enqueuing items" do  
76 - described_class.enqueue SimpleJob.new  
77 - expect(described_class.count).to eq(1)  
78 - end  
79 -  
80 - it "is able to set priority [DEPRECATED]" do  
81 - silence_warnings do  
82 - job = described_class.enqueue SimpleJob.new, 5  
83 - expect(job.priority).to eq(5)  
84 - end  
85 - end  
86 -  
87 - it "uses default priority when it is not set" do  
88 - @job = described_class.enqueue SimpleJob.new  
89 - expect(@job.priority).to eq(99)  
90 - end  
91 -  
92 - it "is able to set run_at [DEPRECATED]" do  
93 - silence_warnings do  
94 - later = described_class.db_time_now + 5.minutes  
95 - @job = described_class.enqueue SimpleJob.new, 5, later  
96 - expect(@job.run_at).to be_within(1).of(later)  
97 - end  
98 - end  
99 -  
100 - it "works with jobs in modules" do  
101 - M::ModuleJob.runs = 0  
102 - job = described_class.enqueue M::ModuleJob.new  
103 - expect{job.invoke_job}.to change { M::ModuleJob.runs }.from(0).to(1)  
104 - end  
105 - end  
106 -  
107 - context "with delay_jobs = false" do  
108 - before(:each) do  
109 - Delayed::Worker.delay_jobs = false  
110 - end  
111 -  
112 - it "does not increase count after enqueuing items" do  
113 - described_class.enqueue SimpleJob.new  
114 - expect(described_class.count).to eq(0)  
115 - end  
116 -  
117 - it "invokes the enqueued job" do  
118 - job = SimpleJob.new  
119 - job.should_receive(:perform)  
120 - described_class.enqueue job  
121 - end  
122 -  
123 - it "returns a job, not the result of invocation" do  
124 - expect(described_class.enqueue(SimpleJob.new)).to be_instance_of(described_class)  
125 - end  
126 - end  
127 - end  
128 -  
129 - describe "callbacks" do  
130 - before(:each) do  
131 - CallbackJob.messages = []  
132 - end  
133 -  
134 - %w(before success after).each do |callback|  
135 - it "calls #{callback} with job" do  
136 - job = described_class.enqueue(CallbackJob.new)  
137 - job.payload_object.should_receive(callback).with(job)  
138 - job.invoke_job  
139 - end  
140 - end  
141 -  
142 - it "calls before and after callbacks" do  
143 - job = described_class.enqueue(CallbackJob.new)  
144 - expect(CallbackJob.messages).to eq(["enqueue"])  
145 - job.invoke_job  
146 - expect(CallbackJob.messages).to eq(["enqueue", "before", "perform", "success", "after"])  
147 - end  
148 -  
149 - it "calls the after callback with an error" do  
150 - job = described_class.enqueue(CallbackJob.new)  
151 - job.payload_object.should_receive(:perform).and_raise(RuntimeError.new("fail"))  
152 -  
153 - expect{job.invoke_job}.to raise_error  
154 - expect(CallbackJob.messages).to eq(["enqueue", "before", "error: RuntimeError", "after"])  
155 - end  
156 -  
157 - it "calls error when before raises an error" do  
158 - job = described_class.enqueue(CallbackJob.new)  
159 - job.payload_object.should_receive(:before).and_raise(RuntimeError.new("fail"))  
160 - expect{job.invoke_job}.to raise_error(RuntimeError)  
161 - expect(CallbackJob.messages).to eq(["enqueue", "error: RuntimeError", "after"])  
162 - end  
163 - end  
164 -  
165 - describe "payload_object" do  
166 - it "raises a DeserializationError when the job class is totally unknown" do  
167 - job = described_class.new :handler => "--- !ruby/object:JobThatDoesNotExist {}"  
168 - expect{job.payload_object}.to raise_error(Delayed::DeserializationError)  
169 - end  
170 -  
171 - it "raises a DeserializationError when the job struct is totally unknown" do  
172 - job = described_class.new :handler => "--- !ruby/struct:StructThatDoesNotExist {}"  
173 - expect{job.payload_object}.to raise_error(Delayed::DeserializationError)  
174 - end  
175 -  
176 - it "raises a DeserializationError when the YAML.load raises argument error" do  
177 - job = described_class.new :handler => "--- !ruby/struct:GoingToRaiseArgError {}"  
178 - YAML.should_receive(:load).and_raise(ArgumentError)  
179 - expect{job.payload_object}.to raise_error(Delayed::DeserializationError)  
180 - end  
181 - end  
182 -  
183 - describe "reserve" do  
184 - before do  
185 - Delayed::Worker.max_run_time = 2.minutes  
186 - end  
187 -  
188 - after do  
189 - Time.zone = nil  
190 - end  
191 -  
192 - it "does not reserve failed jobs" do  
193 - create_job :attempts => 50, :failed_at => described_class.db_time_now  
194 - expect(described_class.reserve(worker)).to be_nil  
195 - end  
196 -  
197 - it "does not reserve jobs scheduled for the future" do  
198 - create_job :run_at => described_class.db_time_now + 1.minute  
199 - expect(described_class.reserve(worker)).to be_nil  
200 - end  
201 -  
202 - it "reserves jobs scheduled for the past" do  
203 - job = create_job :run_at => described_class.db_time_now - 1.minute  
204 - expect(described_class.reserve(worker)).to eq(job)  
205 - end  
206 -  
207 - it "reserves jobs scheduled for the past when time zones are involved" do  
208 - Time.zone = 'US/Eastern'  
209 - job = create_job :run_at => described_class.db_time_now - 1.minute  
210 - expect(described_class.reserve(worker)).to eq(job)  
211 - end  
212 -  
213 - it "does not reserve jobs locked by other workers" do  
214 - job = create_job  
215 - other_worker = Delayed::Worker.new  
216 - other_worker.name = 'other_worker'  
217 - expect(described_class.reserve(other_worker)).to eq(job)  
218 - expect(described_class.reserve(worker)).to be_nil  
219 - end  
220 -  
221 - it "reserves open jobs" do  
222 - job = create_job  
223 - expect(described_class.reserve(worker)).to eq(job)  
224 - end  
225 -  
226 - it "reserves expired jobs" do  
227 - job = create_job(:locked_by => 'some other worker', :locked_at => described_class.db_time_now - Delayed::Worker.max_run_time - 1.minute)  
228 - expect(described_class.reserve(worker)).to eq(job)  
229 - end  
230 -  
231 - it "reserves own jobs" do  
232 - job = create_job(:locked_by => worker.name, :locked_at => (described_class.db_time_now - 1.minutes))  
233 - expect(described_class.reserve(worker)).to eq(job)  
234 - end  
235 - end  
236 -  
237 - context "#name" do  
238 - it "is the class name of the job that was enqueued" do  
239 - expect(described_class.create(:payload_object => ErrorJob.new ).name).to eq('ErrorJob')  
240 - end  
241 -  
242 - it "is the method that will be called if its a performable method object" do  
243 - job = described_class.new(:payload_object => NamedJob.new)  
244 - expect(job.name).to eq('named_job')  
245 - end  
246 -  
247 - it "is the instance method that will be called if its a performable method object" do  
248 - job = Story.create(:text => "...").delay.save  
249 - expect(job.name).to eq('Story#save')  
250 - end  
251 -  
252 - it "parses from handler on deserialization error" do  
253 - job = Story.create(:text => "...").delay.text  
254 - job.payload_object.object.destroy  
255 - expect(job.reload.name).to eq('Delayed::PerformableMethod')  
256 - end  
257 - end  
258 -  
259 - context "worker prioritization" do  
260 - after do  
261 - Delayed::Worker.max_priority = nil  
262 - Delayed::Worker.min_priority = nil  
263 - end  
264 -  
265 - it "fetches jobs ordered by priority" do  
266 - 10.times { described_class.enqueue SimpleJob.new, :priority => rand(10) }  
267 - jobs = []  
268 - 10.times { jobs << described_class.reserve(worker) }  
269 - expect(jobs.size).to eq(10)  
270 - jobs.each_cons(2) do |a, b|  
271 - expect(a.priority).to be <= b.priority  
272 - end  
273 - end  
274 -  
275 - it "only finds jobs greater than or equal to min priority" do  
276 - min = 5  
277 - Delayed::Worker.min_priority = min  
278 - [4,5,6].sort_by {|i| rand }.each {|i| create_job :priority => i }  
279 - 2.times do  
280 - job = described_class.reserve(worker)  
281 - expect(job.priority).to be >= min  
282 - job.destroy  
283 - end  
284 - expect(described_class.reserve(worker)).to be_nil  
285 - end  
286 -  
287 - it "only finds jobs less than or equal to max priority" do  
288 - max = 5  
289 - Delayed::Worker.max_priority = max  
290 - [4,5,6].sort_by {|i| rand }.each {|i| create_job :priority => i }  
291 - 2.times do  
292 - job = described_class.reserve(worker)  
293 - expect(job.priority).to be <= max  
294 - job.destroy  
295 - end  
296 - expect(described_class.reserve(worker)).to be_nil  
297 - end  
298 - end  
299 -  
300 - context "clear_locks!" do  
301 - before do  
302 - @job = create_job(:locked_by => 'worker1', :locked_at => described_class.db_time_now)  
303 - end  
304 -  
305 - it "clears locks for the given worker" do  
306 - described_class.clear_locks!('worker1')  
307 - expect(described_class.reserve(worker)).to eq(@job)  
308 - end  
309 -  
310 - it "does not clear locks for other workers" do  
311 - described_class.clear_locks!('different_worker')  
312 - expect(described_class.reserve(worker)).not_to eq(@job)  
313 - end  
314 - end  
315 -  
316 - context "unlock" do  
317 - before do  
318 - @job = create_job(:locked_by => 'worker', :locked_at => described_class.db_time_now)  
319 - end  
320 -  
321 - it "clears locks" do  
322 - @job.unlock  
323 - expect(@job.locked_by).to be_nil  
324 - expect(@job.locked_at).to be_nil  
325 - end  
326 - end  
327 -  
328 - context "large handler" do  
329 - before do  
330 - text = "Lorem ipsum dolor sit amet. " * 1000  
331 - @job = described_class.enqueue Delayed::PerformableMethod.new(text, :length, {})  
332 - end  
333 -  
334 - it "has an id" do  
335 - expect(@job.id).not_to be_nil  
336 - end  
337 - end  
338 -  
339 - context "named queues" do  
340 - context "when worker has one queue set" do  
341 - before(:each) do  
342 - worker.queues = ['large']  
343 - end  
344 -  
345 - it "only works off jobs which are from its queue" do  
346 - expect(SimpleJob.runs).to eq(0)  
347 -  
348 - create_job(:queue => "large")  
349 - create_job(:queue => "small")  
350 - worker.work_off  
351 -  
352 - expect(SimpleJob.runs).to eq(1)  
353 - end  
354 - end  
355 -  
356 - context "when worker has two queue set" do  
357 - before(:each) do  
358 - worker.queues = ['large', 'small']  
359 - end  
360 -  
361 - it "only works off jobs which are from its queue" do  
362 - expect(SimpleJob.runs).to eq(0)  
363 -  
364 - create_job(:queue => "large")  
365 - create_job(:queue => "small")  
366 - create_job(:queue => "medium")  
367 - create_job  
368 - worker.work_off  
369 -  
370 - expect(SimpleJob.runs).to eq(2)  
371 - end  
372 - end  
373 -  
374 - context "when worker does not have queue set" do  
375 - before(:each) do  
376 - worker.queues = []  
377 - end  
378 -  
379 - it "works off all jobs" do  
380 - expect(SimpleJob.runs).to eq(0)  
381 -  
382 - create_job(:queue => "one")  
383 - create_job(:queue => "two")  
384 - create_job  
385 - worker.work_off  
386 -  
387 - expect(SimpleJob.runs).to eq(3)  
388 - end  
389 - end  
390 - end  
391 -  
392 - context "max_attempts" do  
393 - before(:each) do  
394 - @job = described_class.enqueue SimpleJob.new  
395 - end  
396 -  
397 - it "is not defined" do  
398 - expect(@job.max_attempts).to be_nil  
399 - end  
400 -  
401 - it "uses the max_retries value on the payload when defined" do  
402 - @job.payload_object.stub(:max_attempts).and_return(99)  
403 - expect(@job.max_attempts).to eq(99)  
404 - end  
405 - end  
406 -  
407 - describe "yaml serialization" do  
408 - it "reloads changed attributes" do  
409 - story = Story.create(:text => 'hello')  
410 - job = story.delay.tell  
411 - story.update_attributes :text => 'goodbye'  
412 - expect(job.reload.payload_object.object.text).to eq('goodbye')  
413 - end  
414 -  
415 - it "raises error ArgumentError the record is not persisted" do  
416 - story = Story.new(:text => 'hello')  
417 - if story.respond_to?(:new_record?)  
418 - expect {  
419 - story.delay.tell  
420 - }.to raise_error(ArgumentError, "Jobs cannot be created for records before they've been persisted")  
421 - end  
422 - end  
423 -  
424 - it "raises deserialization error for destroyed records" do  
425 - story = Story.create(:text => 'hello')  
426 - job = story.delay.tell  
427 - story.destroy  
428 - expect {  
429 - job.reload.payload_object  
430 - }.to raise_error(Delayed::DeserializationError)  
431 - end  
432 - end  
433 -  
434 - describe "worker integration" do  
435 - before do  
436 - Delayed::Job.delete_all  
437 - SimpleJob.runs = 0  
438 - end  
439 -  
440 - describe "running a job" do  
441 - it "fails after Worker.max_run_time" do  
442 - Delayed::Worker.max_run_time = 1.second  
443 - job = Delayed::Job.create :payload_object => LongRunningJob.new  
444 - worker.run(job)  
445 - expect(job.reload.last_error).to match(/expired/)  
446 - expect(job.reload.last_error).to match(/Delayed::Worker.max_run_time is only 1 second/)  
447 - expect(job.attempts).to eq(1)  
448 - end  
449 -  
450 - context "when the job raises a deserialization error" do  
451 - after do  
452 - Delayed::Worker.destroy_failed_jobs = true  
453 - end  
454 -  
455 - it "marks the job as failed" do  
456 - Delayed::Worker.destroy_failed_jobs = false  
457 - job = described_class.create! :handler => "--- !ruby/object:JobThatDoesNotExist {}"  
458 - worker.work_off  
459 - job.reload  
460 - expect(job).to be_failed  
461 - end  
462 - end  
463 - end  
464 -  
465 - describe "failed jobs" do  
466 - before do  
467 - @job = Delayed::Job.enqueue(ErrorJob.new, :run_at => described_class.db_time_now - 1)  
468 - end  
469 -  
470 - after do  
471 - # reset default  
472 - Delayed::Worker.destroy_failed_jobs = true  
473 - end  
474 -  
475 - it "records last_error when destroy_failed_jobs = false, max_attempts = 1" do  
476 - Delayed::Worker.destroy_failed_jobs = false  
477 - Delayed::Worker.max_attempts = 1  
478 - worker.run(@job)  
479 - @job.reload  
480 - expect(@job.last_error).to match(/did not work/)  
481 - expect(@job.attempts).to eq(1)  
482 - expect(@job).to be_failed  
483 - end  
484 -  
485 - it "re-schedules jobs after failing" do  
486 - worker.work_off  
487 - @job.reload  
488 - expect(@job.last_error).to match(/did not work/)  
489 - expect(@job.last_error).to match(/sample_jobs.rb:\d+:in `perform'/)  
490 - expect(@job.attempts).to eq(1)  
491 - expect(@job.run_at).to be > Delayed::Job.db_time_now - 10.minutes  
492 - expect(@job.run_at).to be < Delayed::Job.db_time_now + 10.minutes  
493 - expect(@job.locked_by).to be_nil  
494 - expect(@job.locked_at).to be_nil  
495 - end  
496 -  
497 - it "re-schedules jobs with handler provided time if present" do  
498 - job = Delayed::Job.enqueue(CustomRescheduleJob.new(99.minutes))  
499 - worker.run(job)  
500 - job.reload  
501 -  
502 - expect((Delayed::Job.db_time_now + 99.minutes - job.run_at).abs).to be < 1  
503 - end  
504 -  
505 - it "does not fail when the triggered error doesn't have a message" do  
506 - error_with_nil_message = StandardError.new  
507 - error_with_nil_message.stub(:message).and_return nil  
508 - @job.stub(:invoke_job).and_raise error_with_nil_message  
509 - expect{worker.run(@job)}.not_to raise_error  
510 - end  
511 - end  
512 -  
513 - context "reschedule" do  
514 - before do  
515 - @job = Delayed::Job.create :payload_object => SimpleJob.new  
516 - end  
517 -  
518 - share_examples_for "any failure more than Worker.max_attempts times" do  
519 - context "when the job's payload has a #failure hook" do  
520 - before do  
521 - @job = Delayed::Job.create :payload_object => OnPermanentFailureJob.new  
522 - expect(@job.payload_object).to respond_to :failure  
523 - end  
524 -  
525 - it "runs that hook" do  
526 - @job.payload_object.should_receive :failure  
527 - worker.reschedule(@job)  
528 - end  
529 - end  
530 -  
531 - context "when the job's payload has no #failure hook" do  
532 - # It's a little tricky to test this in a straightforward way,  
533 - # because putting a should_not_receive expectation on  
534 - # @job.payload_object.failure makes that object  
535 - # incorrectly return true to  
536 - # payload_object.respond_to? :failure, which is what  
537 - # reschedule uses to decide whether to call failure.  
538 - # So instead, we just make sure that the payload_object as it  
539 - # already stands doesn't respond_to? failure, then  
540 - # shove it through the iterated reschedule loop and make sure we  
541 - # don't get a NoMethodError (caused by calling that nonexistent  
542 - # failure method).  
543 -  
544 - before do  
545 - expect(@job.payload_object).not_to respond_to(:failure)  
546 - end  
547 -  
548 - it "does not try to run that hook" do  
549 - expect {  
550 - Delayed::Worker.max_attempts.times { worker.reschedule(@job) }  
551 - }.not_to raise_exception  
552 - end  
553 - end  
554 - end  
555 -  
556 - context "and we want to destroy jobs" do  
557 - it_should_behave_like "any failure more than Worker.max_attempts times"  
558 -  
559 - it "is destroyed if it failed more than Worker.max_attempts times" do  
560 - @job.should_receive(:destroy)  
561 - Delayed::Worker.max_attempts.times { worker.reschedule(@job) }  
562 - end  
563 -  
564 - it "is not destroyed if failed fewer than Worker.max_attempts times" do  
565 - @job.should_not_receive(:destroy)  
566 - (Delayed::Worker.max_attempts - 1).times { worker.reschedule(@job) }  
567 - end  
568 - end  
569 -  
570 - context "and we don't want to destroy jobs" do  
571 - before do  
572 - Delayed::Worker.destroy_failed_jobs = false  
573 - end  
574 -  
575 - after do  
576 - Delayed::Worker.destroy_failed_jobs = true  
577 - end  
578 -  
579 - it_should_behave_like "any failure more than Worker.max_attempts times"  
580 -  
581 - it "is failed if it failed more than Worker.max_attempts times" do  
582 - expect(@job.reload).not_to be_failed  
583 - Delayed::Worker.max_attempts.times { worker.reschedule(@job) }  
584 - expect(@job.reload).to be_failed  
585 - end  
586 -  
587 - it "is not failed if it failed fewer than Worker.max_attempts times" do  
588 - (Delayed::Worker.max_attempts - 1).times { worker.reschedule(@job) }  
589 - expect(@job.reload).not_to be_failed  
590 - end  
591 - end  
592 - end  
593 - end  
594 -end  
vendor/plugins/delayed_job/lib/delayed/command.rb
@@ -1,111 +0,0 @@ @@ -1,111 +0,0 @@
1 -begin  
2 - require 'daemons'  
3 -rescue LoadError  
4 - raise "You need to add gem 'daemons' to your Gemfile if you wish to use it."  
5 -end  
6 -require 'optparse'  
7 -  
8 -module Delayed  
9 - class Command  
10 - attr_accessor :worker_count  
11 -  
12 - def initialize(args)  
13 - @options = {  
14 - :quiet => true,  
15 - :pid_dir => "#{Rails.root}/tmp/pids"  
16 - }  
17 -  
18 - @worker_count = 1  
19 - @monitor = false  
20 -  
21 - opts = OptionParser.new do |opts|  
22 - opts.banner = "Usage: #{File.basename($0)} [options] start|stop|restart|run"  
23 -  
24 - opts.on('-h', '--help', 'Show this message') do  
25 - puts opts  
26 - exit 1  
27 - end  
28 - opts.on('-e', '--environment=NAME', 'Specifies the environment to run this delayed jobs under (test/development/production).') do |e|  
29 - STDERR.puts "The -e/--environment option has been deprecated and has no effect. Use RAILS_ENV and see http://github.com/collectiveidea/delayed_job/issues/#issue/7"  
30 - end  
31 - opts.on('--min-priority N', 'Minimum priority of jobs to run.') do |n|  
32 - @options[:min_priority] = n  
33 - end  
34 - opts.on('--max-priority N', 'Maximum priority of jobs to run.') do |n|  
35 - @options[:max_priority] = n  
36 - end  
37 - opts.on('-n', '--number_of_workers=workers', "Number of unique workers to spawn") do |worker_count|  
38 - @worker_count = worker_count.to_i rescue 1  
39 - end  
40 - opts.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|  
41 - @options[:pid_dir] = dir  
42 - end  
43 - opts.on('-i', '--identifier=n', 'A numeric identifier for the worker.') do |n|  
44 - @options[:identifier] = n  
45 - end  
46 - opts.on('-m', '--monitor', 'Start monitor process.') do  
47 - @monitor = true  
48 - end  
49 - opts.on('--sleep-delay N', "Amount of time to sleep when no jobs are found") do |n|  
50 - @options[:sleep_delay] = n.to_i  
51 - end  
52 - opts.on('--read-ahead N', "Number of jobs from the queue to consider") do |n|  
53 - @options[:read_ahead] = n  
54 - end  
55 - opts.on('-p', '--prefix NAME', "String to be prefixed to worker process names") do |prefix|  
56 - @options[:prefix] = prefix  
57 - end  
58 - opts.on('--queues=queues', "Specify which queue DJ must look up for jobs") do |queues|  
59 - @options[:queues] = queues.split(',')  
60 - end  
61 - opts.on('--queue=queue', "Specify which queue DJ must look up for jobs") do |queue|  
62 - @options[:queues] = queue.split(',')  
63 - end  
64 - opts.on('--exit-on-complete', "Exit when no more jobs are available to run. This will exit if all jobs are scheduled to run in the future.") do  
65 - @options[:exit_on_complete] = true  
66 - end  
67 - end  
68 - @args = opts.parse!(args)  
69 - end  
70 -  
71 - def daemonize  
72 - dir = @options[:pid_dir]  
73 - Dir.mkdir(dir) unless File.exists?(dir)  
74 -  
75 - if @worker_count > 1 && @options[:identifier]  
76 - raise ArgumentError, 'Cannot specify both --number-of-workers and --identifier'  
77 - elsif @worker_count == 1 && @options[:identifier]  
78 - process_name = "delayed_job.#{@options[:identifier]}"  
79 - run_process(process_name, dir)  
80 - else  
81 - worker_count.times do |worker_index|  
82 - process_name = worker_count == 1 ? "delayed_job" : "delayed_job.#{worker_index}"  
83 - run_process(process_name, dir)  
84 - end  
85 - end  
86 - end  
87 -  
88 - def run_process(process_name, dir)  
89 - Delayed::Worker.before_fork  
90 - Daemons.run_proc(process_name, :dir => dir, :dir_mode => :normal, :monitor => @monitor, :ARGV => @args) do |*args|  
91 - $0 = File.join(@options[:prefix], process_name) if @options[:prefix]  
92 - run process_name  
93 - end  
94 - end  
95 -  
96 - def run(worker_name = nil)  
97 - Dir.chdir(Rails.root)  
98 -  
99 - Delayed::Worker.after_fork  
100 - Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', "#{Rails.env}_delayed_job.log"))  
101 -  
102 - worker = Delayed::Worker.new(@options)  
103 - worker.name_prefix = "#{worker_name} "  
104 - worker.start  
105 - rescue => e  
106 - Rails.logger.fatal e  
107 - STDERR.puts e.message  
108 - exit 1  
109 - end  
110 - end  
111 -end  
vendor/plugins/delayed_job/lib/delayed/compatibility.rb
@@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
1 -require 'active_support/version'  
2 -  
3 -module Delayed  
4 - module Compatibility  
5 - if ActiveSupport::VERSION::MAJOR >= 4  
6 - require 'active_support/proxy_object'  
7 -  
8 - def self.executable_prefix  
9 - 'bin'  
10 - end  
11 -  
12 - def self.proxy_object_class  
13 - ActiveSupport::ProxyObject  
14 - end  
15 - else  
16 - require 'active_support/basic_object'  
17 -  
18 - def self.executable_prefix  
19 - 'script'  
20 - end  
21 -  
22 - def self.proxy_object_class  
23 - ActiveSupport::BasicObject  
24 - end  
25 - end  
26 - end  
27 -end  
vendor/plugins/delayed_job/lib/delayed/deserialization_error.rb
@@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
1 -module Delayed  
2 - class DeserializationError < StandardError  
3 - end  
4 -end  
vendor/plugins/delayed_job/lib/delayed/exceptions.rb
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 -require 'timeout'  
2 -  
3 -module Delayed  
4 - class WorkerTimeout < Timeout::Error  
5 - def message  
6 - "#{super} (Delayed::Worker.max_run_time is only #{Delayed::Worker.max_run_time.to_i} seconds)"  
7 - end  
8 - end  
9 -end  
vendor/plugins/delayed_job/lib/delayed/lifecycle.rb
@@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
1 -module Delayed  
2 - class InvalidCallback < Exception; end  
3 -  
4 - class Lifecycle  
5 - EVENTS = {  
6 - :enqueue => [:job],  
7 - :execute => [:worker],  
8 - :loop => [:worker],  
9 - :perform => [:worker, :job],  
10 - :error => [:worker, :job],  
11 - :failure => [:worker, :job],  
12 - :invoke_job => [:job]  
13 - }  
14 -  
15 - def initialize  
16 - @callbacks = EVENTS.keys.inject({}) { |hash, e| hash[e] = Callback.new; hash }  
17 - end  
18 -  
19 - def before(event, &block)  
20 - add(:before, event, &block)  
21 - end  
22 -  
23 - def after(event, &block)  
24 - add(:after, event, &block)  
25 - end  
26 -  
27 - def around(event, &block)  
28 - add(:around, event, &block)  
29 - end  
30 -  
31 - def run_callbacks(event, *args, &block)  
32 - missing_callback(event) unless @callbacks.has_key?(event)  
33 -  
34 - unless EVENTS[event].size == args.size  
35 - raise ArgumentError, "Callback #{event} expects #{EVENTS[event].size} parameter(s): #{EVENTS[event].join(', ')}"  
36 - end  
37 -  
38 - @callbacks[event].execute(*args, &block)  
39 - end  
40 -  
41 - private  
42 -  
43 - def add(type, event, &block)  
44 - missing_callback(event) unless @callbacks.has_key?(event)  
45 -  
46 - @callbacks[event].add(type, &block)  
47 - end  
48 -  
49 - def missing_callback(event)  
50 - raise InvalidCallback, "Unknown callback event: #{event}"  
51 - end  
52 - end  
53 -  
54 - class Callback  
55 - def initialize  
56 - @before = []  
57 - @after = []  
58 -  
59 - # Identity proc. Avoids special cases when there is no existing around chain.  
60 - @around = lambda { |*args, &block| block.call(*args) }  
61 - end  
62 -  
63 - def execute(*args, &block)  
64 - @before.each { |c| c.call(*args) }  
65 - result = @around.call(*args, &block)  
66 - @after.each { |c| c.call(*args) }  
67 - result  
68 - end  
69 -  
70 - def add(type, &callback)  
71 - case type  
72 - when :before  
73 - @before << callback  
74 - when :after  
75 - @after << callback  
76 - when :around  
77 - chain = @around # use a local variable so that the current chain is closed over in the following lambda  
78 - @around = lambda { |*a, &block| chain.call(*a) { |*b| callback.call(*b, &block) } }  
79 - else  
80 - raise InvalidCallback, "Invalid callback type: #{type}"  
81 - end  
82 - end  
83 - end  
84 -end  
vendor/plugins/delayed_job/lib/delayed/message_sending.rb
@@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
1 -require 'active_support/core_ext/module/aliasing'  
2 -  
3 -module Delayed  
4 - class DelayProxy < Delayed::Compatibility.proxy_object_class  
5 - def initialize(payload_class, target, options)  
6 - @payload_class = payload_class  
7 - @target = target  
8 - @options = options  
9 - end  
10 -  
11 - def method_missing(method, *args)  
12 - Job.enqueue({:payload_object => @payload_class.new(@target, method.to_sym, args)}.merge(@options))  
13 - end  
14 - end  
15 -  
16 - module MessageSending  
17 - def delay(options = {})  
18 - DelayProxy.new(PerformableMethod, self, options)  
19 - end  
20 - alias __delay__ delay  
21 -  
22 - def send_later(method, *args)  
23 - warn "[DEPRECATION] `object.send_later(:method)` is deprecated. Use `object.delay.method"  
24 - __delay__.__send__(method, *args)  
25 - end  
26 -  
27 - def send_at(time, method, *args)  
28 - warn "[DEPRECATION] `object.send_at(time, :method)` is deprecated. Use `object.delay(:run_at => time).method"  
29 - __delay__(:run_at => time).__send__(method, *args)  
30 - end  
31 -  
32 - module ClassMethods  
33 - def handle_asynchronously(method, opts = {})  
34 - aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1  
35 - with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}"  
36 - define_method(with_method) do |*args|  
37 - curr_opts = opts.clone  
38 - curr_opts.each_key do |key|  
39 - if (val = curr_opts[key]).is_a?(Proc)  
40 - curr_opts[key] = if val.arity == 1  
41 - val.call(self)  
42 - else  
43 - val.call  
44 - end  
45 - end  
46 - end  
47 - delay(curr_opts).__send__(without_method, *args)  
48 - end  
49 - alias_method_chain method, :delay  
50 - end  
51 - end  
52 - end  
53 -end  
vendor/plugins/delayed_job/lib/delayed/performable_mailer.rb
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -require 'mail'  
2 -  
3 -module Delayed  
4 - class PerformableMailer < PerformableMethod  
5 - def perform  
6 - object.send(method_name, *args).deliver  
7 - end  
8 - end  
9 -  
10 - module DelayMail  
11 - def delay(options = {})  
12 - DelayProxy.new(PerformableMailer, self, options)  
13 - end  
14 - end  
15 -end  
16 -  
17 -Mail::Message.class_eval do  
18 - def delay(*args)  
19 - raise RuntimeError, "Use MyMailer.delay.mailer_action(args) to delay sending of emails."  
20 - end  
21 -end  
vendor/plugins/delayed_job/lib/delayed/performable_method.rb
@@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
1 -require 'active_support/core_ext/module/delegation'  
2 -  
3 -module Delayed  
4 - class PerformableMethod  
5 - attr_accessor :object, :method_name, :args  
6 -  
7 - delegate :method, :to => :object  
8 -  
9 - def initialize(object, method_name, args)  
10 - raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true)  
11 -  
12 - if object.respond_to?(:new_record?) && object.new_record?  
13 - raise(ArgumentError, 'Jobs cannot be created for records before they\'ve been persisted')  
14 - end  
15 -  
16 - self.object = object  
17 - self.args = args  
18 - self.method_name = method_name.to_sym  
19 - end  
20 -  
21 - def display_name  
22 - "#{object.class}##{method_name}"  
23 - end  
24 -  
25 - def perform  
26 - object.send(method_name, *args) if object  
27 - end  
28 -  
29 - def method_missing(symbol, *args)  
30 - object.send(symbol, *args)  
31 - end  
32 -  
33 - def respond_to?(symbol, include_private=false)  
34 - super || object.respond_to?(symbol, include_private)  
35 - end  
36 - end  
37 -end  
vendor/plugins/delayed_job/lib/delayed/plugin.rb
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -require 'active_support/core_ext/class/attribute'  
2 -  
3 -module Delayed  
4 - class Plugin  
5 - class_attribute :callback_block  
6 -  
7 - def self.callbacks(&block)  
8 - self.callback_block = block  
9 - end  
10 -  
11 - def initialize  
12 - self.class.callback_block.call(Delayed::Worker.lifecycle) if self.class.callback_block  
13 - end  
14 - end  
15 -end  
vendor/plugins/delayed_job/lib/delayed/plugins/clear_locks.rb
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -module Delayed  
2 - module Plugins  
3 - class ClearLocks < Plugin  
4 - callbacks do |lifecycle|  
5 - lifecycle.around(:execute) do |worker, &block|  
6 - begin  
7 - block.call(worker)  
8 - ensure  
9 - Delayed::Job.clear_locks!(worker.name)  
10 - end  
11 - end  
12 - end  
13 - end  
14 - end  
15 -end  
vendor/plugins/delayed_job/lib/delayed/psych_ext.rb
@@ -1,146 +0,0 @@ @@ -1,146 +0,0 @@
1 -if defined?(ActiveRecord)  
2 - ActiveRecord::Base.class_eval do  
3 - if instance_methods.include?(:encode_with)  
4 - def encode_with_override(coder)  
5 - encode_with_without_override(coder)  
6 - coder.tag = "!ruby/ActiveRecord:#{self.class.name}"  
7 - end  
8 - alias_method :encode_with_without_override, :encode_with  
9 - alias_method :encode_with, :encode_with_override  
10 - else  
11 - def encode_with(coder)  
12 - coder["attributes"] = attributes  
13 - coder.tag = "!ruby/ActiveRecord:#{self.class.name}"  
14 - end  
15 - end  
16 - end  
17 -end  
18 -  
19 -class Delayed::PerformableMethod  
20 - # serialize to YAML  
21 - def encode_with(coder)  
22 - coder.map = {  
23 - "object" => object,  
24 - "method_name" => method_name,  
25 - "args" => args  
26 - }  
27 - end  
28 -end  
29 -  
30 -module Psych  
31 - module Visitors  
32 - class YAMLTree  
33 - def visit_Class(klass)  
34 - @emitter.scalar klass.name, nil, '!ruby/class', false, false, Nodes::Scalar::SINGLE_QUOTED  
35 - end  
36 - end  
37 -  
38 - class ToRuby  
39 - def visit_Psych_Nodes_Scalar(o)  
40 - @st[o.anchor] = o.value if o.anchor  
41 -  
42 - if klass = Psych.load_tags[o.tag]  
43 - instance = klass.allocate  
44 -  
45 - if instance.respond_to?(:init_with)  
46 - coder = Psych::Coder.new(o.tag)  
47 - coder.scalar = o.value  
48 - instance.init_with coder  
49 - end  
50 -  
51 - return instance  
52 - end  
53 -  
54 - return o.value if o.quoted  
55 - return @ss.tokenize(o.value) unless o.tag  
56 -  
57 - case o.tag  
58 - when '!binary', 'tag:yaml.org,2002:binary'  
59 - o.value.unpack('m').first  
60 - when '!str', 'tag:yaml.org,2002:str'  
61 - o.value  
62 - when "!ruby/object:DateTime"  
63 - require 'date'  
64 - @ss.parse_time(o.value).to_datetime  
65 - when "!ruby/object:Complex"  
66 - Complex(o.value)  
67 - when "!ruby/object:Rational"  
68 - Rational(o.value)  
69 - when "!ruby/class", "!ruby/module"  
70 - resolve_class o.value  
71 - when "tag:yaml.org,2002:float", "!float"  
72 - Float(@ss.tokenize(o.value))  
73 - when "!ruby/regexp"  
74 - o.value =~ /^\/(.*)\/([mixn]*)$/  
75 - source = $1  
76 - options = 0  
77 - lang = nil  
78 - ($2 || '').split('').each do |option|  
79 - case option  
80 - when 'x' then options |= Regexp::EXTENDED  
81 - when 'i' then options |= Regexp::IGNORECASE  
82 - when 'm' then options |= Regexp::MULTILINE  
83 - when 'n' then options |= Regexp::NOENCODING  
84 - else lang = option  
85 - end  
86 - end  
87 - Regexp.new(*[source, options, lang].compact)  
88 - when "!ruby/range"  
89 - args = o.value.split(/([.]{2,3})/, 2).map { |s|  
90 - accept Nodes::Scalar.new(s)  
91 - }  
92 - args.push(args.delete_at(1) == '...')  
93 - Range.new(*args)  
94 - when /^!ruby\/sym(bol)?:?(.*)?$/  
95 - o.value.to_sym  
96 - else  
97 - @ss.tokenize o.value  
98 - end  
99 - end  
100 -  
101 - def visit_Psych_Nodes_Mapping_with_class(object)  
102 - return revive(Psych.load_tags[object.tag], object) if Psych.load_tags[object.tag]  
103 -  
104 - case object.tag  
105 - when /^!ruby\/ActiveRecord:(.+)$/  
106 - klass = resolve_class($1)  
107 - payload = Hash[*object.children.map { |c| accept c }]  
108 - id = payload["attributes"][klass.primary_key]  
109 - begin  
110 - klass.unscoped.find(id)  
111 - rescue ActiveRecord::RecordNotFound  
112 - raise Delayed::DeserializationError  
113 - end  
114 - when /^!ruby\/Mongoid:(.+)$/  
115 - klass = resolve_class($1)  
116 - payload = Hash[*object.children.map { |c| accept c }]  
117 - begin  
118 - klass.find(payload["attributes"]["_id"])  
119 - rescue Mongoid::Errors::DocumentNotFound  
120 - raise Delayed::DeserializationError  
121 - end  
122 - when /^!ruby\/DataMapper:(.+)$/  
123 - klass = resolve_class($1)  
124 - payload = Hash[*object.children.map { |c| accept c }]  
125 - begin  
126 - primary_keys = klass.properties.select { |p| p.key? }  
127 - key_names = primary_keys.map { |p| p.name.to_s }  
128 - klass.get!(*key_names.map { |k| payload["attributes"][k] })  
129 - rescue DataMapper::ObjectNotFoundError  
130 - raise Delayed::DeserializationError  
131 - end  
132 - else  
133 - visit_Psych_Nodes_Mapping_without_class(object)  
134 - end  
135 - end  
136 - alias_method_chain :visit_Psych_Nodes_Mapping, :class  
137 -  
138 - def resolve_class_with_constantize(klass_name)  
139 - klass_name.constantize  
140 - rescue  
141 - resolve_class_without_constantize(klass_name)  
142 - end  
143 - alias_method_chain :resolve_class, :constantize  
144 - end  
145 - end  
146 -end  
vendor/plugins/delayed_job/lib/delayed/railtie.rb
@@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
1 -require 'delayed_job'  
2 -require 'rails'  
3 -  
4 -module Delayed  
5 - class Railtie < Rails::Railtie  
6 - initializer :after_initialize do  
7 - ActiveSupport.on_load(:action_mailer) do  
8 - ActionMailer::Base.send(:extend, Delayed::DelayMail)  
9 - end  
10 - end  
11 -  
12 - rake_tasks do  
13 - load 'delayed/tasks.rb'  
14 - end  
15 - end  
16 -end  
vendor/plugins/delayed_job/lib/delayed/recipes.rb
@@ -1,54 +0,0 @@ @@ -1,54 +0,0 @@
1 -# Capistrano Recipes for managing delayed_job  
2 -#  
3 -# Add these callbacks to have the delayed_job process restart when the server  
4 -# is restarted:  
5 -#  
6 -# after "deploy:stop", "delayed_job:stop"  
7 -# after "deploy:start", "delayed_job:start"  
8 -# after "deploy:restart", "delayed_job:restart"  
9 -#  
10 -# If you want to use command line options, for example to start multiple workers,  
11 -# define a Capistrano variable delayed_job_args:  
12 -#  
13 -# set :delayed_job_args, "-n 2"  
14 -#  
15 -# If you've got delayed_job workers running on a servers, you can also specify  
16 -# which servers have delayed_job running and should be restarted after deploy.  
17 -#  
18 -# set :delayed_job_server_role, :worker  
19 -#  
20 -  
21 -Capistrano::Configuration.instance.load do  
22 - namespace :delayed_job do  
23 - def rails_env  
24 - fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''  
25 - end  
26 -  
27 - def args  
28 - fetch(:delayed_job_args, "")  
29 - end  
30 -  
31 - def roles  
32 - fetch(:delayed_job_server_role, :app)  
33 - end  
34 -  
35 - def delayed_job_command  
36 - fetch(:delayed_job_command, "script/delayed_job")  
37 - end  
38 -  
39 - desc "Stop the delayed_job process"  
40 - task :stop, :roles => lambda { roles } do  
41 - run "cd #{current_path};#{rails_env} #{delayed_job_command} stop"  
42 - end  
43 -  
44 - desc "Start the delayed_job process"  
45 - task :start, :roles => lambda { roles } do  
46 - run "cd #{current_path};#{rails_env} #{delayed_job_command} start #{args}"  
47 - end  
48 -  
49 - desc "Restart the delayed_job process"  
50 - task :restart, :roles => lambda { roles } do  
51 - run "cd #{current_path};#{rails_env} #{delayed_job_command} restart #{args}"  
52 - end  
53 - end  
54 -end  
vendor/plugins/delayed_job/lib/delayed/serialization/active_record.rb
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -if defined?(ActiveRecord)  
2 - class ActiveRecord::Base  
3 - yaml_as "tag:ruby.yaml.org,2002:ActiveRecord"  
4 -  
5 - def self.yaml_new(klass, tag, val)  
6 - klass.unscoped.find(val['attributes'][klass.primary_key])  
7 - rescue ActiveRecord::RecordNotFound  
8 - raise Delayed::DeserializationError, "ActiveRecord::RecordNotFound, class: #{klass} , primary key: #{val['attributes'][klass.primary_key]} "  
9 - end  
10 -  
11 - def to_yaml_properties  
12 - ['@attributes']  
13 - end  
14 - end  
15 -end  
vendor/plugins/delayed_job/lib/delayed/syck_ext.rb
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -class Module  
2 - yaml_as "tag:ruby.yaml.org,2002:module"  
3 -  
4 - def self.yaml_new(klass, tag, val)  
5 - val.constantize  
6 - end  
7 -  
8 - def to_yaml(options = {})  
9 - YAML.quick_emit(nil, options) do |out|  
10 - out.scalar(taguri, name, :plain)  
11 - end  
12 - end  
13 -  
14 - def yaml_tag_read_class(name)  
15 - # Constantize the object so that ActiveSupport can attempt  
16 - # its auto loading magic. Will raise LoadError if not successful.  
17 - name.constantize  
18 - name  
19 - end  
20 -end  
21 -  
22 -class Class  
23 - yaml_as "tag:ruby.yaml.org,2002:class"  
24 - remove_method :to_yaml if respond_to?(:to_yaml) && method(:to_yaml).owner == Class # use Module's to_yaml  
25 -end  
26 -  
27 -class Struct  
28 - def self.yaml_tag_read_class(name)  
29 - # Constantize the object so that ActiveSupport can attempt  
30 - # its auto loading magic. Will raise LoadError if not successful.  
31 - name.constantize  
32 - "Struct::#{ name }"  
33 - end  
34 -end  
vendor/plugins/delayed_job/lib/delayed/tasks.rb
@@ -1,38 +0,0 @@ @@ -1,38 +0,0 @@
1 -namespace :jobs do  
2 - desc "Clear the delayed_job queue."  
3 - task :clear => :environment do  
4 - Delayed::Job.delete_all  
5 - end  
6 -  
7 - desc "Start a delayed_job worker."  
8 - task :work => :environment_options do  
9 - Delayed::Worker.new(@worker_options).start  
10 - end  
11 -  
12 - desc "Start a delayed_job worker and exit when all available jobs are complete."  
13 - task :workoff => :environment_options do  
14 - Delayed::Worker.new(@worker_options.merge({:exit_on_complete => true})).start  
15 - end  
16 -  
17 - task :environment_options => :environment do  
18 - @worker_options = {  
19 - :min_priority => ENV['MIN_PRIORITY'],  
20 - :max_priority => ENV['MAX_PRIORITY'],  
21 - :queues => (ENV['QUEUES'] || ENV['QUEUE'] || '').split(','),  
22 - :quiet => false  
23 - }  
24 - end  
25 -  
26 - desc "Exit with error status if any jobs older than max_age seconds haven't been attempted yet."  
27 - task :check, [:max_age] => :environment do |_, args|  
28 - args.with_defaults(:max_age => 300)  
29 -  
30 - unprocessed_jobs = Delayed::Job.where('attempts = 0 AND created_at < ?', Time.now - args[:max_age].to_i).count  
31 -  
32 - if unprocessed_jobs > 0  
33 - fail "#{unprocessed_jobs} jobs older than #{args[:max_age]} seconds have not been processed yet"  
34 - end  
35 -  
36 - end  
37 -  
38 -end  
vendor/plugins/delayed_job/lib/delayed/worker.rb
@@ -1,283 +0,0 @@ @@ -1,283 +0,0 @@
1 -require 'timeout'  
2 -require 'active_support/core_ext/numeric/time'  
3 -require 'active_support/core_ext/class/attribute_accessors'  
4 -require 'active_support/core_ext/kernel'  
5 -require 'active_support/core_ext/enumerable'  
6 -require 'logger'  
7 -require 'benchmark'  
8 -  
9 -module Delayed  
10 - class Worker  
11 - DEFAULT_LOG_LEVEL = Logger::INFO  
12 - DEFAULT_SLEEP_DELAY = 5  
13 - DEFAULT_MAX_ATTEMPTS = 25  
14 - DEFAULT_MAX_RUN_TIME = 4.hours  
15 - DEFAULT_DEFAULT_PRIORITY = 0  
16 - DEFAULT_DELAY_JOBS = true  
17 - DEFAULT_QUEUES = []  
18 - DEFAULT_READ_AHEAD = 5  
19 -  
20 - cattr_accessor :min_priority, :max_priority, :max_attempts, :max_run_time,  
21 - :default_priority, :sleep_delay, :logger, :delay_jobs, :queues,  
22 - :read_ahead, :plugins, :destroy_failed_jobs, :exit_on_complete  
23 -  
24 - # Named queue into which jobs are enqueued by default  
25 - cattr_accessor :default_queue_name  
26 -  
27 - cattr_reader :backend  
28 -  
29 - # name_prefix is ignored if name is set directly  
30 - attr_accessor :name_prefix  
31 -  
32 - def self.reset  
33 - self.sleep_delay = DEFAULT_SLEEP_DELAY  
34 - self.max_attempts = DEFAULT_MAX_ATTEMPTS  
35 - self.max_run_time = DEFAULT_MAX_RUN_TIME  
36 - self.default_priority = DEFAULT_DEFAULT_PRIORITY  
37 - self.delay_jobs = DEFAULT_DELAY_JOBS  
38 - self.queues = DEFAULT_QUEUES  
39 - self.read_ahead = DEFAULT_READ_AHEAD  
40 - end  
41 -  
42 - reset  
43 -  
44 - # Add or remove plugins in this list before the worker is instantiated  
45 - self.plugins = [Delayed::Plugins::ClearLocks]  
46 -  
47 - # By default failed jobs are destroyed after too many attempts. If you want to keep them around  
48 - # (perhaps to inspect the reason for the failure), set this to false.  
49 - self.destroy_failed_jobs = true  
50 -  
51 - # By default, Signals INT and TERM set @exit, and the worker exits upon completion of the current job.  
52 - # If you would prefer to raise a SignalException and exit immediately you can use this.  
53 - # Be aware daemons uses TERM to stop and restart  
54 - # false - No exceptions will be raised  
55 - # :term - Will only raise an exception on TERM signals but INT will wait for the current job to finish  
56 - # true - Will raise an exception on TERM and INT  
57 - cattr_accessor :raise_signal_exceptions  
58 - self.raise_signal_exceptions = false  
59 -  
60 - self.logger = if defined?(Rails)  
61 - Rails.logger  
62 - elsif defined?(RAILS_DEFAULT_LOGGER)  
63 - RAILS_DEFAULT_LOGGER  
64 - end  
65 -  
66 - def self.backend=(backend)  
67 - if backend.is_a? Symbol  
68 - require "delayed/serialization/#{backend}"  
69 - require "delayed/backend/#{backend}"  
70 - backend = "Delayed::Backend::#{backend.to_s.classify}::Job".constantize  
71 - end  
72 - @@backend = backend  
73 - silence_warnings { ::Delayed.const_set(:Job, backend) }  
74 - end  
75 -  
76 - def self.guess_backend  
77 - warn "[DEPRECATION] guess_backend is deprecated. Please remove it from your code."  
78 - end  
79 -  
80 - def self.before_fork  
81 - unless @files_to_reopen  
82 - @files_to_reopen = []  
83 - ObjectSpace.each_object(File) do |file|  
84 - @files_to_reopen << file unless file.closed?  
85 - end  
86 - end  
87 -  
88 - backend.before_fork  
89 - end  
90 -  
91 - def self.after_fork  
92 - # Re-open file handles  
93 - @files_to_reopen.each do |file|  
94 - begin  
95 - file.reopen file.path, "a+"  
96 - file.sync = true  
97 - rescue ::Exception  
98 - end  
99 - end  
100 -  
101 - backend.after_fork  
102 - end  
103 -  
104 - def self.lifecycle  
105 - @lifecycle ||= Delayed::Lifecycle.new  
106 - end  
107 -  
108 - def initialize(options={})  
109 - @quiet = options.has_key?(:quiet) ? options[:quiet] : true  
110 - @failed_reserve_count = 0  
111 -  
112 - [:min_priority, :max_priority, :sleep_delay, :read_ahead, :queues, :exit_on_complete].each do |option|  
113 - self.class.send("#{option}=", options[option]) if options.has_key?(option)  
114 - end  
115 -  
116 - self.plugins.each { |klass| klass.new }  
117 - end  
118 -  
119 - # Every worker has a unique name which by default is the pid of the process. There are some  
120 - # advantages to overriding this with something which survives worker restarts: Workers can  
121 - # safely resume working on tasks which are locked by themselves. The worker will assume that  
122 - # it crashed before.  
123 - def name  
124 - return @name unless @name.nil?  
125 - "#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}" rescue "#{@name_prefix}pid:#{Process.pid}"  
126 - end  
127 -  
128 - # Sets the name of the worker.  
129 - # Setting the name to nil will reset the default worker name  
130 - def name=(val)  
131 - @name = val  
132 - end  
133 -  
134 - def start  
135 - trap('TERM') do  
136 - say 'Exiting...'  
137 - stop  
138 - raise SignalException.new('TERM') if self.class.raise_signal_exceptions  
139 - end  
140 -  
141 - trap('INT') do  
142 - say 'Exiting...'  
143 - stop  
144 - raise SignalException.new('INT') if self.class.raise_signal_exceptions && self.class.raise_signal_exceptions != :term  
145 - end  
146 -  
147 - say "Starting job worker"  
148 -  
149 - self.class.lifecycle.run_callbacks(:execute, self) do  
150 - loop do  
151 - self.class.lifecycle.run_callbacks(:loop, self) do  
152 - @realtime = Benchmark.realtime do  
153 - @result = work_off  
154 - end  
155 - end  
156 -  
157 - count = @result.sum  
158 -  
159 - if count.zero?  
160 - if self.class.exit_on_complete  
161 - say "No more jobs available. Exiting"  
162 - break  
163 - else  
164 - sleep(self.class.sleep_delay) unless stop?  
165 - end  
166 - else  
167 - say "#{count} jobs processed at %.4f j/s, %d failed" % [count / @realtime, @result.last]  
168 - end  
169 -  
170 - break if stop?  
171 - end  
172 - end  
173 - end  
174 -  
175 - def stop  
176 - @exit = true  
177 - end  
178 -  
179 - def stop?  
180 - !!@exit  
181 - end  
182 -  
183 - # Do num jobs and return stats on success/failure.  
184 - # Exit early if interrupted.  
185 - def work_off(num = 100)  
186 - success, failure = 0, 0  
187 -  
188 - num.times do  
189 - case reserve_and_run_one_job  
190 - when true  
191 - success += 1  
192 - when false  
193 - failure += 1  
194 - else  
195 - break # leave if no work could be done  
196 - end  
197 - break if stop? # leave if we're exiting  
198 - end  
199 -  
200 - return [success, failure]  
201 - end  
202 -  
203 - def run(job)  
204 - job_say job, 'RUNNING'  
205 - runtime = Benchmark.realtime do  
206 - Timeout.timeout(self.class.max_run_time.to_i, WorkerTimeout) { job.invoke_job }  
207 - job.destroy  
208 - end  
209 - job_say job, 'COMPLETED after %.4f' % runtime  
210 - return true # did work  
211 - rescue DeserializationError => error  
212 - job.last_error = "#{error.message}\n#{error.backtrace.join("\n")}"  
213 - failed(job)  
214 - rescue Exception => error  
215 - self.class.lifecycle.run_callbacks(:error, self, job){ handle_failed_job(job, error) }  
216 - return false # work failed  
217 - end  
218 -  
219 - # Reschedule the job in the future (when a job fails).  
220 - # Uses an exponential scale depending on the number of failed attempts.  
221 - def reschedule(job, time = nil)  
222 - if (job.attempts += 1) < max_attempts(job)  
223 - time ||= job.reschedule_at  
224 - job.run_at = time  
225 - job.unlock  
226 - job.save!  
227 - else  
228 - job_say job, "REMOVED permanently because of #{job.attempts} consecutive failures", Logger::ERROR  
229 - failed(job)  
230 - end  
231 - end  
232 -  
233 - def failed(job)  
234 - self.class.lifecycle.run_callbacks(:failure, self, job) do  
235 - job.hook(:failure)  
236 - self.class.destroy_failed_jobs ? job.destroy : job.fail!  
237 - end  
238 - end  
239 -  
240 - def job_say(job, text, level = DEFAULT_LOG_LEVEL)  
241 - text = "Job #{job.name} (id=#{job.id}) #{text}"  
242 - say text, level  
243 - end  
244 -  
245 - def say(text, level = DEFAULT_LOG_LEVEL)  
246 - text = "[Worker(#{name})] #{text}"  
247 - puts text unless @quiet  
248 - logger.add level, "#{Time.now.strftime('%FT%T%z')}: #{text}" if logger  
249 - end  
250 -  
251 - def max_attempts(job)  
252 - job.max_attempts || self.class.max_attempts  
253 - end  
254 -  
255 - protected  
256 -  
257 - def handle_failed_job(job, error)  
258 - job.last_error = "#{error.message}\n#{error.backtrace.join("\n")}"  
259 - job_say job, "FAILED (#{job.attempts} prior attempts) with #{error.class.name}: #{error.message}", Logger::ERROR  
260 - reschedule(job)  
261 - end  
262 -  
263 - # Run the next job we can get an exclusive lock on.  
264 - # If no jobs are left we return nil  
265 - def reserve_and_run_one_job  
266 - job = reserve_job  
267 - self.class.lifecycle.run_callbacks(:perform, self, job){ run(job) } if job  
268 - end  
269 -  
270 - def reserve_job  
271 - job = Delayed::Job.reserve(self)  
272 - @failed_reserve_count = 0  
273 - job  
274 - rescue Exception => error  
275 - say "Error while reserving job: #{error}"  
276 - Delayed::Job.recover_from(error)  
277 - @failed_reserve_count += 1  
278 - raise FatalBackendError if @failed_reserve_count >= 10  
279 - nil  
280 - end  
281 - end  
282 -  
283 -end  
vendor/plugins/delayed_job/lib/delayed/yaml_ext.rb
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -# These extensions allow properly serializing and autoloading of  
2 -# Classes, Modules and Structs  
3 -  
4 -require 'yaml'  
5 -if YAML.parser.class.name =~ /syck|yecht/i  
6 - require File.expand_path('../syck_ext', __FILE__)  
7 - require File.expand_path('../serialization/active_record', __FILE__)  
8 -else  
9 - require File.expand_path('../psych_ext', __FILE__)  
10 -end  
vendor/plugins/delayed_job/lib/delayed_job.rb
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -require 'active_support'  
2 -require 'delayed/compatibility'  
3 -require 'delayed/exceptions'  
4 -require 'delayed/message_sending'  
5 -require 'delayed/performable_method'  
6 -  
7 -if defined?(ActionMailer)  
8 - require 'action_mailer/version'  
9 - require 'delayed/performable_mailer'  
10 -end  
11 -  
12 -require 'delayed/yaml_ext'  
13 -require 'delayed/lifecycle'  
14 -require 'delayed/plugin'  
15 -require 'delayed/plugins/clear_locks'  
16 -require 'delayed/backend/base'  
17 -require 'delayed/worker'  
18 -require 'delayed/deserialization_error'  
19 -require 'delayed/railtie' if defined?(Rails::Railtie)  
20 -  
21 -Object.send(:include, Delayed::MessageSending)  
22 -Module.send(:include, Delayed::MessageSending::ClassMethods)  
vendor/plugins/delayed_job/lib/generators/delayed_job/delayed_job_generator.rb
@@ -1,12 +0,0 @@ @@ -1,12 +0,0 @@
1 -require 'rails/generators'  
2 -require 'delayed/compatibility'  
3 -  
4 -class DelayedJobGenerator < Rails::Generators::Base  
5 -  
6 - self.source_paths << File.join(File.dirname(__FILE__), 'templates')  
7 -  
8 - def create_executable_file  
9 - template "script", "#{Delayed::Compatibility.executable_prefix}/delayed_job"  
10 - chmod "#{Delayed::Compatibility.executable_prefix}/delayed_job", 0755  
11 - end  
12 -end  
vendor/plugins/delayed_job/lib/generators/delayed_job/templates/script
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -#!/usr/bin/env ruby  
2 -  
3 -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))  
4 -require 'delayed/command'  
5 -Delayed::Command.new(ARGV).daemonize  
vendor/plugins/delayed_job/recipes/delayed_job.rb
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'delayed', 'recipes'))  
vendor/plugins/delayed_job/spec/autoloaded/clazz.rb
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -# Make sure this file does not get required manually  
2 -module Autoloaded  
3 - class Clazz  
4 - def perform  
5 - end  
6 - end  
7 -end  
vendor/plugins/delayed_job/spec/autoloaded/instance_clazz.rb
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -module Autoloaded  
2 - class InstanceClazz  
3 - def perform  
4 - end  
5 - end  
6 -end  
vendor/plugins/delayed_job/spec/autoloaded/instance_struct.rb
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -module Autoloaded  
2 - class InstanceStruct < ::Struct.new(nil)  
3 - def perform  
4 - end  
5 - end  
6 -end  
vendor/plugins/delayed_job/spec/autoloaded/struct.rb
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -# Make sure this file does not get required manually  
2 -module Autoloaded  
3 - class Struct < ::Struct.new(nil)  
4 - def perform  
5 - end  
6 - end  
7 -end  
vendor/plugins/delayed_job/spec/delayed/backend/test.rb
@@ -1,112 +0,0 @@ @@ -1,112 +0,0 @@
1 -require 'ostruct'  
2 -  
3 -# An in-memory backend suitable only for testing. Tries to behave as if it were an ORM.  
4 -module Delayed  
5 - module Backend  
6 - module Test  
7 - class Job  
8 - attr_accessor :id  
9 - attr_accessor :priority  
10 - attr_accessor :attempts  
11 - attr_accessor :handler  
12 - attr_accessor :last_error  
13 - attr_accessor :run_at  
14 - attr_accessor :locked_at  
15 - attr_accessor :locked_by  
16 - attr_accessor :failed_at  
17 - attr_accessor :queue  
18 -  
19 - include Delayed::Backend::Base  
20 -  
21 - cattr_accessor :id  
22 - self.id = 0  
23 -  
24 - def initialize(hash = {})  
25 - self.attempts = 0  
26 - self.priority = 0  
27 - self.id = (self.class.id += 1)  
28 - hash.each{|k,v| send(:"#{k}=", v)}  
29 - end  
30 -  
31 - @jobs = []  
32 - def self.all  
33 - @jobs  
34 - end  
35 -  
36 - def self.count  
37 - all.size  
38 - end  
39 -  
40 - def self.delete_all  
41 - all.clear  
42 - end  
43 -  
44 - def self.create(attrs = {})  
45 - new(attrs).tap do |o|  
46 - o.save  
47 - end  
48 - end  
49 -  
50 - def self.create!(*args); create(*args); end  
51 -  
52 - def self.clear_locks!(worker_name)  
53 - all.select{|j| j.locked_by == worker_name}.each {|j| j.locked_by = nil; j.locked_at = nil}  
54 - end  
55 -  
56 - # Find a few candidate jobs to run (in case some immediately get locked by others).  
57 - def self.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_time)  
58 - jobs = all.select do |j|  
59 - j.run_at <= db_time_now &&  
60 - (j.locked_at.nil? || j.locked_at < db_time_now - max_run_time || j.locked_by == worker_name) &&  
61 - !j.failed?  
62 - end  
63 -  
64 - jobs = jobs.select{|j| Worker.queues.include?(j.queue)} if Worker.queues.any?  
65 - jobs = jobs.select{|j| j.priority >= Worker.min_priority} if Worker.min_priority  
66 - jobs = jobs.select{|j| j.priority <= Worker.max_priority} if Worker.max_priority  
67 - jobs.sort_by{|j| [j.priority, j.run_at]}[0..limit-1]  
68 - end  
69 -  
70 - # Lock this job for this worker.  
71 - # Returns true if we have the lock, false otherwise.  
72 - def lock_exclusively!(max_run_time, worker)  
73 - now = self.class.db_time_now  
74 - if locked_by != worker  
75 - # We don't own this job so we will update the locked_by name and the locked_at  
76 - self.locked_at = now  
77 - self.locked_by = worker  
78 - end  
79 -  
80 - return true  
81 - end  
82 -  
83 - def self.db_time_now  
84 - Time.current  
85 - end  
86 -  
87 - def update_attributes(attrs = {})  
88 - attrs.each{|k,v| send(:"#{k}=", v)}  
89 - save  
90 - end  
91 -  
92 - def destroy  
93 - self.class.all.delete(self)  
94 - end  
95 -  
96 - def save  
97 - self.run_at ||= Time.current  
98 -  
99 - self.class.all << self unless self.class.all.include?(self)  
100 - true  
101 - end  
102 -  
103 - def save!; save; end  
104 -  
105 - def reload  
106 - reset  
107 - self  
108 - end  
109 - end  
110 - end  
111 - end  
112 -end  
vendor/plugins/delayed_job/spec/delayed/serialization/test.rb
vendor/plugins/delayed_job/spec/helper.rb
@@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
1 -require 'logger'  
2 -require 'rspec'  
3 -  
4 -require 'action_mailer'  
5 -require 'active_support/dependencies'  
6 -require 'active_record'  
7 -  
8 -require 'delayed_job'  
9 -require 'delayed/backend/shared_spec'  
10 -  
11 -require 'simplecov'  
12 -require 'coveralls'  
13 -  
14 -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[  
15 - SimpleCov::Formatter::HTMLFormatter,  
16 - Coveralls::SimpleCov::Formatter  
17 -]  
18 -SimpleCov.start  
19 -  
20 -Delayed::Worker.logger = Logger.new('/tmp/dj.log')  
21 -ENV['RAILS_ENV'] = 'test'  
22 -  
23 -Delayed::Worker.backend = :test  
24 -  
25 -# Add this directory so the ActiveSupport autoloading works  
26 -ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__)  
27 -  
28 -# Add this to simulate Railtie initializer being executed  
29 -ActionMailer::Base.send(:extend, Delayed::DelayMail)  
30 -  
31 -  
32 -# Used to test interactions between DJ and an ORM  
33 -ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'  
34 -ActiveRecord::Base.logger = Delayed::Worker.logger  
35 -ActiveRecord::Migration.verbose = false  
36 -  
37 -ActiveRecord::Schema.define do  
38 - create_table :stories, :primary_key => :story_id, :force => true do |table|  
39 - table.string :text  
40 - table.boolean :scoped, :default => true  
41 - end  
42 -end  
43 -  
44 -class Story < ActiveRecord::Base  
45 - self.primary_key = 'story_id'  
46 - def tell; text; end  
47 - def whatever(n, _); tell*n; end  
48 - default_scope { where(:scoped => true) }  
49 -  
50 - handle_asynchronously :whatever  
51 -end  
52 -  
53 -RSpec.configure do |config|  
54 - config.after(:each) do  
55 - Delayed::Worker.reset  
56 - end  
57 -  
58 - config.expect_with :rspec do |c|  
59 - c.syntax = :expect  
60 - end  
61 -end  
vendor/plugins/delayed_job/spec/lifecycle_spec.rb
@@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe Delayed::Lifecycle do  
4 - let(:lifecycle) { Delayed::Lifecycle.new }  
5 - let(:callback) { lambda {|*args|} }  
6 - let(:arguments) { [1] }  
7 - let(:behavior) { double(Object, :before! => nil, :after! => nil, :inside! => nil) }  
8 - let(:wrapped_block) { Proc.new { behavior.inside! } }  
9 -  
10 - describe "before callbacks" do  
11 - before(:each) do  
12 - lifecycle.before(:execute, &callback)  
13 - end  
14 -  
15 - it "executes before wrapped block" do  
16 - callback.should_receive(:call).with(*arguments).ordered  
17 - behavior.should_receive(:inside!).ordered  
18 - lifecycle.run_callbacks :execute, *arguments, &wrapped_block  
19 - end  
20 - end  
21 -  
22 - describe "after callbacks" do  
23 - before(:each) do  
24 - lifecycle.after(:execute, &callback)  
25 - end  
26 -  
27 - it "executes after wrapped block" do  
28 - behavior.should_receive(:inside!).ordered  
29 - callback.should_receive(:call).with(*arguments).ordered  
30 - lifecycle.run_callbacks :execute, *arguments, &wrapped_block  
31 - end  
32 - end  
33 -  
34 - describe "around callbacks" do  
35 - before(:each) do  
36 - lifecycle.around(:execute) do |*args, &block|  
37 - behavior.before!  
38 - block.call(*args)  
39 - behavior.after!  
40 - end  
41 - end  
42 -  
43 - it "wraps a block" do  
44 - behavior.should_receive(:before!).ordered  
45 - behavior.should_receive(:inside!).ordered  
46 - behavior.should_receive(:after!).ordered  
47 - lifecycle.run_callbacks :execute, *arguments, &wrapped_block  
48 - end  
49 -  
50 - it "executes multiple callbacks in order" do  
51 - behavior.should_receive(:one).ordered  
52 - behavior.should_receive(:two).ordered  
53 - behavior.should_receive(:three).ordered  
54 -  
55 - lifecycle.around(:execute) { |*args, &block| behavior.one; block.call(*args) }  
56 - lifecycle.around(:execute) { |*args, &block| behavior.two; block.call(*args) }  
57 - lifecycle.around(:execute) { |*args, &block| behavior.three; block.call(*args) }  
58 -  
59 - lifecycle.run_callbacks(:execute, *arguments, &wrapped_block)  
60 - end  
61 - end  
62 -  
63 - it "raises if callback is executed with wrong number of parameters" do  
64 - lifecycle.before(:execute, &callback)  
65 - expect { lifecycle.run_callbacks(:execute, 1,2,3) {} }.to raise_error(ArgumentError, /1 parameter/)  
66 - end  
67 -end  
vendor/plugins/delayed_job/spec/message_sending_spec.rb
@@ -1,122 +0,0 @@ @@ -1,122 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe Delayed::MessageSending do  
4 - describe "handle_asynchronously" do  
5 - class Story  
6 - def tell!(arg);end  
7 - handle_asynchronously :tell!  
8 - end  
9 -  
10 - it "aliases original method" do  
11 - expect(Story.new).to respond_to(:tell_without_delay!)  
12 - expect(Story.new).to respond_to(:tell_with_delay!)  
13 - end  
14 -  
15 - it "creates a PerformableMethod" do  
16 - story = Story.create  
17 - expect {  
18 - job = story.tell!(1)  
19 - expect(job.payload_object.class).to eq(Delayed::PerformableMethod)  
20 - expect(job.payload_object.method_name).to eq(:tell_without_delay!)  
21 - expect(job.payload_object.args).to eq([1])  
22 - }.to change { Delayed::Job.count }  
23 - end  
24 -  
25 - describe "with options" do  
26 - class Fable  
27 - cattr_accessor :importance  
28 - def tell;end  
29 - handle_asynchronously :tell, :priority => Proc.new { self.importance }  
30 - end  
31 -  
32 - it "sets the priority based on the Fable importance" do  
33 - Fable.importance = 10  
34 - job = Fable.new.tell  
35 - expect(job.priority).to eq(10)  
36 -  
37 - Fable.importance = 20  
38 - job = Fable.new.tell  
39 - expect(job.priority).to eq(20)  
40 - end  
41 -  
42 - describe "using a proc with parameters" do  
43 - class Yarn  
44 - attr_accessor :importance  
45 - def spin  
46 - end  
47 - handle_asynchronously :spin, :priority => Proc.new {|y| y.importance }  
48 - end  
49 -  
50 - it "sets the priority based on the Fable importance" do  
51 - job = Yarn.new.tap {|y| y.importance = 10 }.spin  
52 - expect(job.priority).to eq(10)  
53 -  
54 - job = Yarn.new.tap {|y| y.importance = 20 }.spin  
55 - expect(job.priority).to eq(20)  
56 - end  
57 - end  
58 - end  
59 - end  
60 -  
61 - context "delay" do  
62 - class FairyTail  
63 - attr_accessor :happy_ending  
64 - def self.princesses;end  
65 - def tell  
66 - @happy_ending = true  
67 - end  
68 - end  
69 -  
70 - after do  
71 - Delayed::Worker.default_queue_name = nil  
72 - end  
73 -  
74 - it "creates a new PerformableMethod job" do  
75 - expect {  
76 - job = "hello".delay.count('l')  
77 - expect(job.payload_object.class).to eq(Delayed::PerformableMethod)  
78 - expect(job.payload_object.method_name).to eq(:count)  
79 - expect(job.payload_object.args).to eq(['l'])  
80 - }.to change { Delayed::Job.count }.by(1)  
81 - end  
82 -  
83 - it "sets default priority" do  
84 - Delayed::Worker.default_priority = 99  
85 - job = FairyTail.delay.to_s  
86 - expect(job.priority).to eq(99)  
87 - end  
88 -  
89 - it "sets default queue name" do  
90 - Delayed::Worker.default_queue_name = 'abbazabba'  
91 - job = FairyTail.delay.to_s  
92 - expect(job.queue).to eq('abbazabba')  
93 - end  
94 -  
95 - it "sets job options" do  
96 - run_at = Time.parse('2010-05-03 12:55 AM')  
97 - job = FairyTail.delay(:priority => 20, :run_at => run_at).to_s  
98 - expect(job.run_at).to eq(run_at)  
99 - expect(job.priority).to eq(20)  
100 - end  
101 -  
102 - it "does not delay the job when delay_jobs is false" do  
103 - Delayed::Worker.delay_jobs = false  
104 - fairy_tail = FairyTail.new  
105 - expect {  
106 - expect {  
107 - fairy_tail.delay.tell  
108 - }.to change(fairy_tail, :happy_ending).from(nil).to(true)  
109 - }.not_to change { Delayed::Job.count }  
110 - end  
111 -  
112 - it "does delay the job when delay_jobs is true" do  
113 - Delayed::Worker.delay_jobs = true  
114 - fairy_tail = FairyTail.new  
115 - expect {  
116 - expect {  
117 - fairy_tail.delay.tell  
118 - }.not_to change(fairy_tail, :happy_ending)  
119 - }.to change { Delayed::Job.count }.by(1)  
120 - end  
121 - end  
122 -end  
vendor/plugins/delayed_job/spec/performable_mailer_spec.rb
@@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
1 -require 'helper'  
2 -  
3 -require 'action_mailer'  
4 -class MyMailer < ActionMailer::Base  
5 - def signup(email)  
6 - mail :to => email, :subject => "Delaying Emails", :from => "delayedjob@example.com",:body => 'Delaying Emails Body'  
7 - end  
8 -end  
9 -  
10 -describe ActionMailer::Base do  
11 - describe "delay" do  
12 - it "enqueues a PerformableEmail job" do  
13 - expect {  
14 - job = MyMailer.delay.signup('john@example.com')  
15 - expect(job.payload_object.class).to eq(Delayed::PerformableMailer)  
16 - expect(job.payload_object.method_name).to eq(:signup)  
17 - expect(job.payload_object.args).to eq(['john@example.com'])  
18 - }.to change { Delayed::Job.count }.by(1)  
19 - end  
20 - end  
21 -  
22 - describe "delay on a mail object" do  
23 - it "raises an exception" do  
24 - expect {  
25 - MyMailer.signup('john@example.com').delay  
26 - }.to raise_error(RuntimeError)  
27 - end  
28 - end  
29 -  
30 - describe Delayed::PerformableMailer do  
31 - describe "perform" do  
32 - it "calls the method and #deliver on the mailer" do  
33 - email = double('email', :deliver => true)  
34 - mailer_class = double('MailerClass', :signup => email)  
35 - mailer = Delayed::PerformableMailer.new(mailer_class, :signup, ['john@example.com'])  
36 -  
37 - mailer_class.should_receive(:signup).with('john@example.com')  
38 - email.should_receive(:deliver)  
39 - mailer.perform  
40 - end  
41 - end  
42 - end  
43 -  
44 -end  
vendor/plugins/delayed_job/spec/performable_method_spec.rb
@@ -1,136 +0,0 @@ @@ -1,136 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe Delayed::PerformableMethod do  
4 - describe "perform" do  
5 - before do  
6 - @method = Delayed::PerformableMethod.new("foo", :count, ['o'])  
7 - end  
8 -  
9 - context "with the persisted record cannot be found" do  
10 - before do  
11 - @method.object = nil  
12 - end  
13 -  
14 - it "does nothing if object is nil" do  
15 - expect{@method.perform}.not_to raise_error  
16 - end  
17 - end  
18 -  
19 - it "calls the method on the object" do  
20 - @method.object.should_receive(:count).with('o')  
21 - @method.perform  
22 - end  
23 - end  
24 -  
25 - it "raises a NoMethodError if target method doesn't exist" do  
26 - expect {  
27 - Delayed::PerformableMethod.new(Object, :method_that_does_not_exist, [])  
28 - }.to raise_error(NoMethodError)  
29 - end  
30 -  
31 - it "does not raise NoMethodError if target method is private" do  
32 - clazz = Class.new do  
33 - def private_method  
34 - end  
35 - private :private_method  
36 - end  
37 - expect {  
38 - Delayed::PerformableMethod.new(clazz.new, :private_method, [])  
39 - }.not_to raise_error  
40 - end  
41 -  
42 - describe "hooks" do  
43 - %w(before after success).each do |hook|  
44 - it "delegates #{hook} hook to object" do  
45 - story = Story.create  
46 - job = story.delay.tell  
47 -  
48 - story.should_receive(hook).with(job)  
49 - job.invoke_job  
50 - end  
51 - end  
52 -  
53 - %w(before after success).each do |hook|  
54 - it "delegates #{hook} hook to object" do  
55 - story = Story.create  
56 - job = story.delay.tell  
57 -  
58 - story.should_receive(hook).with(job)  
59 - job.invoke_job  
60 - end  
61 - end  
62 -  
63 - it "delegates enqueue hook to object" do  
64 - story = Story.create  
65 - story.should_receive(:enqueue).with(an_instance_of(Delayed::Job))  
66 - story.delay.tell  
67 - end  
68 -  
69 - it "delegates error hook to object" do  
70 - story = Story.create  
71 - story.should_receive(:error).with(an_instance_of(Delayed::Job), an_instance_of(RuntimeError))  
72 - story.should_receive(:tell).and_raise(RuntimeError)  
73 - expect { story.delay.tell.invoke_job }.to raise_error  
74 - end  
75 -  
76 - it "delegates error hook to object when delay_jobs = false" do  
77 - story = Story.create  
78 - story.should_receive(:error).with(an_instance_of(Delayed::Job), an_instance_of(RuntimeError))  
79 - story.should_receive(:tell).and_raise(RuntimeError)  
80 - expect { story.delay.tell.invoke_job }.to raise_error  
81 - end  
82 -  
83 - it "delegates failure hook to object" do  
84 - method = Delayed::PerformableMethod.new("object", :size, [])  
85 - method.object.should_receive(:failure)  
86 - method.failure  
87 - end  
88 -  
89 - context 'with delay_job == false' do  
90 - before do  
91 - Delayed::Worker.delay_jobs = false  
92 - end  
93 -  
94 - after do  
95 - Delayed::Worker.delay_jobs = true  
96 - end  
97 -  
98 - %w(before after success).each do |hook|  
99 - it "delegates #{hook} hook to object" do  
100 - story = Story.create  
101 - story.should_receive(hook).with(an_instance_of(Delayed::Job))  
102 - story.delay.tell  
103 - end  
104 - end  
105 -  
106 - %w(before after success).each do |hook|  
107 - it "delegates #{hook} hook to object" do  
108 - story = Story.create  
109 - story.should_receive(hook).with(an_instance_of(Delayed::Job))  
110 - story.delay.tell  
111 - end  
112 - end  
113 -  
114 - it "delegates error hook to object" do  
115 - story = Story.create  
116 - story.should_receive(:error).with(an_instance_of(Delayed::Job), an_instance_of(RuntimeError))  
117 - story.should_receive(:tell).and_raise(RuntimeError)  
118 - expect { story.delay.tell }.to raise_error  
119 - end  
120 -  
121 - it "delegates error hook to object when delay_jobs = false" do  
122 - story = Story.create  
123 - story.should_receive(:error).with(an_instance_of(Delayed::Job), an_instance_of(RuntimeError))  
124 - story.should_receive(:tell).and_raise(RuntimeError)  
125 - expect { story.delay.tell }.to raise_error  
126 - end  
127 -  
128 - it "delegates failure hook to object when delay_jobs = false" do  
129 - Delayed::Worker.delay_jobs = false  
130 - method = Delayed::PerformableMethod.new("object", :size, [])  
131 - method.object.should_receive(:failure)  
132 - method.failure  
133 - end  
134 - end  
135 - end  
136 -end  
vendor/plugins/delayed_job/spec/sample_jobs.rb
@@ -1,75 +0,0 @@ @@ -1,75 +0,0 @@
1 -class NamedJob < Struct.new(:perform)  
2 - def display_name  
3 - 'named_job'  
4 - end  
5 -end  
6 -  
7 -class SimpleJob  
8 - cattr_accessor :runs; self.runs = 0  
9 - def perform; @@runs += 1; end  
10 -end  
11 -  
12 -class ErrorJob  
13 - cattr_accessor :runs; self.runs = 0  
14 - def perform; raise 'did not work'; end  
15 -end  
16 -  
17 -class CustomRescheduleJob < Struct.new(:offset)  
18 - cattr_accessor :runs; self.runs = 0  
19 - def perform; raise 'did not work'; end  
20 - def reschedule_at(time, attempts); time + offset; end  
21 -end  
22 -  
23 -class LongRunningJob  
24 - def perform; sleep 250; end  
25 -end  
26 -  
27 -class OnPermanentFailureJob < SimpleJob  
28 - def failure; end  
29 - def max_attempts; 1; end  
30 -end  
31 -  
32 -module M  
33 - class ModuleJob  
34 - cattr_accessor :runs; self.runs = 0  
35 - def perform; @@runs += 1; end  
36 - end  
37 -end  
38 -  
39 -class CallbackJob  
40 - cattr_accessor :messages  
41 -  
42 - def enqueue(job)  
43 - self.class.messages << 'enqueue'  
44 - end  
45 -  
46 - def before(job)  
47 - self.class.messages << 'before'  
48 - end  
49 -  
50 - def perform  
51 - self.class.messages << 'perform'  
52 - end  
53 -  
54 - def after(job)  
55 - self.class.messages << 'after'  
56 - end  
57 -  
58 - def success(job)  
59 - self.class.messages << 'success'  
60 - end  
61 -  
62 - def error(job, error)  
63 - self.class.messages << "error: #{error.class}"  
64 - end  
65 -  
66 - def failure(job)  
67 - self.class.messages << 'failure'  
68 - end  
69 -end  
70 -  
71 -class EnqueueJobMod < SimpleJob  
72 - def enqueue(job)  
73 - job.run_at = 20.minutes.from_now  
74 - end  
75 -end  
vendor/plugins/delayed_job/spec/test_backend_spec.rb
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe Delayed::Backend::Test::Job do  
4 - it_should_behave_like 'a delayed_job backend'  
5 -  
6 - describe "#reload" do  
7 - it "causes the payload object to be reloaded" do  
8 - job = "foo".delay.length  
9 - o = job.payload_object  
10 - expect(o.object_id).not_to eq(job.reload.payload_object.object_id)  
11 - end  
12 - end  
13 -end  
vendor/plugins/delayed_job/spec/worker_spec.rb
@@ -1,102 +0,0 @@ @@ -1,102 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe Delayed::Worker do  
4 - describe "backend=" do  
5 - before do  
6 - @clazz = Class.new  
7 - Delayed::Worker.backend = @clazz  
8 - end  
9 -  
10 - after do  
11 - Delayed::Worker.backend = :test  
12 - end  
13 -  
14 - it "sets the Delayed::Job constant to the backend" do  
15 - expect(Delayed::Job).to eq(@clazz)  
16 - end  
17 -  
18 - it "sets backend with a symbol" do  
19 - Delayed::Worker.backend = :test  
20 - expect(Delayed::Worker.backend).to eq(Delayed::Backend::Test::Job)  
21 - end  
22 - end  
23 -  
24 - describe "job_say" do  
25 - before do  
26 - @worker = Delayed::Worker.new  
27 - @job = double('job', :id => 123, :name => 'ExampleJob')  
28 - end  
29 -  
30 - it "logs with job name and id" do  
31 - @worker.should_receive(:say).  
32 - with('Job ExampleJob (id=123) message', Delayed::Worker::DEFAULT_LOG_LEVEL)  
33 - @worker.job_say(@job, 'message')  
34 - end  
35 - end  
36 -  
37 - context "worker read-ahead" do  
38 - before do  
39 - @read_ahead = Delayed::Worker.read_ahead  
40 - end  
41 -  
42 - after do  
43 - Delayed::Worker.read_ahead = @read_ahead  
44 - end  
45 -  
46 - it "reads five jobs" do  
47 - Delayed::Job.should_receive(:find_available).with(anything, 5, anything).and_return([])  
48 - Delayed::Job.reserve(Delayed::Worker.new)  
49 - end  
50 -  
51 - it "reads a configurable number of jobs" do  
52 - Delayed::Worker.read_ahead = 15  
53 - Delayed::Job.should_receive(:find_available).with(anything, Delayed::Worker.read_ahead, anything).and_return([])  
54 - Delayed::Job.reserve(Delayed::Worker.new)  
55 - end  
56 - end  
57 -  
58 - context "worker exit on complete" do  
59 - before do  
60 - Delayed::Worker.exit_on_complete = true  
61 - end  
62 -  
63 - after do  
64 - Delayed::Worker.exit_on_complete = false  
65 - end  
66 -  
67 - it "exits the loop when no jobs are available" do  
68 - worker = Delayed::Worker.new  
69 - Timeout::timeout(2) do  
70 - worker.start  
71 - end  
72 - end  
73 - end  
74 -  
75 - context "worker job reservation" do  
76 - before do  
77 - Delayed::Worker.exit_on_complete = true  
78 - end  
79 -  
80 - after do  
81 - Delayed::Worker.exit_on_complete = false  
82 - end  
83 -  
84 - it "handles error during job reservation" do  
85 - Delayed::Job.should_receive(:reserve).and_raise(Exception)  
86 - Delayed::Worker.new.work_off  
87 - end  
88 -  
89 - it "gives up after 10 backend failures" do  
90 - Delayed::Job.stub(:reserve).and_raise(Exception)  
91 - worker = Delayed::Worker.new  
92 - 9.times { worker.work_off }  
93 - expect(lambda { worker.work_off }).to raise_exception  
94 - end  
95 -  
96 - it "allows the backend to attempt recovery from reservation errors" do  
97 - Delayed::Job.should_receive(:reserve).and_raise(Exception)  
98 - Delayed::Job.should_receive(:recover_from).with(instance_of(Exception))  
99 - Delayed::Worker.new.work_off  
100 - end  
101 - end  
102 -end  
vendor/plugins/delayed_job/spec/yaml_ext_spec.rb
@@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe "YAML" do  
4 - it "autoloads classes" do  
5 - expect {  
6 - yaml = "--- !ruby/class Autoloaded::Clazz\n"  
7 - expect(YAML.load(yaml)).to eq(Autoloaded::Clazz)  
8 - }.not_to raise_error  
9 - end  
10 -  
11 - it "autoloads the class of a struct" do  
12 - expect {  
13 - yaml = "--- !ruby/class Autoloaded::Struct\n"  
14 - expect(YAML.load(yaml)).to eq(Autoloaded::Struct)  
15 - }.not_to raise_error  
16 - end  
17 -  
18 - it "autoloads the class for the instance of a struct" do  
19 - expect {  
20 - yaml = "--- !ruby/struct:Autoloaded::InstanceStruct {}"  
21 - expect(YAML.load(yaml).class).to eq(Autoloaded::InstanceStruct)  
22 - }.not_to raise_error  
23 - end  
24 -  
25 - it "autoloads the class for the instance" do  
26 - expect {  
27 - yaml = "--- !ruby/object:Autoloaded::InstanceClazz {}\n"  
28 - expect(YAML.load(yaml).class).to eq(Autoloaded::InstanceClazz)  
29 - }.not_to raise_error  
30 - end  
31 -  
32 - it "does not throw an uninitialized constant Syck::Syck when using YAML.load with poorly formed yaml" do  
33 - expect{ YAML.load(YAML.dump("foo: *bar"))}.not_to raise_error  
34 - end  
35 -end  
vendor/plugins/delayed_job_active_record/.rspec
@@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
1 ---color  
2 ---fail-fast  
vendor/plugins/delayed_job_active_record/.travis.yml
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -language: ruby  
2 -before_script:  
3 - - mysql -e 'create database delayed_job_test;'  
4 - - psql -c 'create database delayed_job_test;' -U postgres  
5 -script: bundle exec rspec  
6 -gemfile:  
7 - - gemfiles/mysql/3-0.gemfile  
8 - - gemfiles/mysql/3-1.gemfile  
9 - - gemfiles/mysql/3-2.gemfile  
10 - - gemfiles/mysql/4-0.gemfile  
11 - - gemfiles/postgresql/3-0.gemfile  
12 - - gemfiles/postgresql/3-1.gemfile  
13 - - gemfiles/postgresql/3-2.gemfile  
14 - - gemfiles/postgresql/4-0.gemfile  
15 - - gemfiles/sqlite3/3-0.gemfile  
16 - - gemfiles/sqlite3/3-1.gemfile  
17 - - gemfiles/sqlite3/3-2.gemfile  
18 - - gemfiles/sqlite3/4-0.gemfile  
19 - - gemfiles/sqlite3/4-0-protected_attributes.gemfile  
20 -rvm:  
21 - - rbx-19mode  
22 - - jruby-19mode  
23 - - 1.9.3  
24 - - 2.0.0  
25 -matrix:  
26 - allow_failures:  
27 - - rvm: rbx-19mode  
28 - - rvm: jruby-19mode  
vendor/plugins/delayed_job_active_record/CONTRIBUTING.md
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -## How to contribute  
2 -  
3 -If you find what looks like a bug:  
4 -  
5 -* Search the [mailing list](http://groups.google.com/group/delayed_job) to see if anyone else had the same issue.  
6 -* Check the [GitHub issue tracker](http://github.com/collectiveidea/delayed_job_active_record/issues/) to see if anyone else has reported issue.  
7 -* If you don't see anything, create an issue with information on how to reproduce it.  
8 -  
9 -If you want to contribute an enhancement or a fix:  
10 -  
11 -* Fork the project on github.  
12 -* Make your changes with tests.  
13 -* Commit the changes without making changes to the Rakefile or any other files that aren't related to your enhancement or fix  
14 -* Send a pull request.  
vendor/plugins/delayed_job_active_record/Gemfile
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbcmysql-adapter'  
8 - gem 'jdbc-mysql'  
9 -  
10 - gem 'activerecord-jdbcpostgresql-adapter'  
11 - gem 'jdbc-postgres'  
12 -  
13 - gem 'activerecord-jdbcsqlite3-adapter'  
14 - gem 'jdbc-sqlite3'  
15 - end  
16 -  
17 - platforms :ruby, :mswin, :mingw do  
18 - gem 'mysql', '~> 2.8.1'  
19 - gem 'pg'  
20 - gem 'sqlite3'  
21 - end  
22 -  
23 - gem 'coveralls', :require => false  
24 - gem 'rspec', '>= 2.11'  
25 - gem 'simplecov', :require => false  
26 -end  
27 -  
28 -gemspec  
vendor/plugins/delayed_job_active_record/LICENSE.md
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -Copyright (c) 2005 Tobias Lütke  
2 -  
3 -Permission is hereby granted, free of charge, to any person obtaining  
4 -a copy of this software and associated documentation files (the  
5 -"Software"), to deal in the Software without restriction, including  
6 -without limitation the rights to use, copy, modify, merge, publish,  
7 -distribute, sublicense, and/or sell copies of the Software, and to  
8 -permit persons to whom the Software is furnished to do so, subject to  
9 -the following conditions:  
10 -  
11 -The above copyright notice and this permission notice shall be  
12 -included in all copies or substantial portions of the Software.  
13 -  
14 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  
15 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
16 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND  
17 -NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE  
18 -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION  
19 -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
20 -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
vendor/plugins/delayed_job_active_record/README.md
@@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
1 -# DelayedJob ActiveRecord Backend  
2 -  
3 -[![Gem Version](https://badge.fury.io/rb/delayed_job_active_record.png)](https://rubygems.org/gems/delayed_job_active_record)  
4 -[![Build Status](https://travis-ci.org/collectiveidea/delayed_job_active_record.png)](https://travis-ci.org/collectiveidea/delayed_job_active_record)  
5 -[![Dependency Status](https://gemnasium.com/collectiveidea/delayed_job_active_record.png)](https://gemnasium.com/collectiveidea/delayed_job_active_record)  
6 -[![Code Climate](https://codeclimate.com/github/collectiveidea/delayed_job_active_record.png)](https://codeclimate.com/github/collectiveidea/delayed_job_active_record)  
7 -[![Coverage Status](https://coveralls.io/repos/collectiveidea/delayed_job_active_record/badge.png?branch=master)](https://coveralls.io/r/collectiveidea/delayed_job_active_record)  
8 -  
9 -## Installation  
10 -  
11 -Add the gem to your Gemfile:  
12 -  
13 - gem 'delayed_job_active_record'  
14 -  
15 -Run `bundle install`.  
16 -  
17 -If you're using Rails, run the generator to create the migration for the  
18 -delayed_job table.  
19 -  
20 - rails g delayed_job:active_record  
21 - rake db:migrate  
22 -  
23 -## Upgrading from 2.x to 3.0.0  
24 -  
25 -If you're upgrading from Delayed Job 2.x, run the upgrade generator to create a  
26 -migration to add a column to your delayed_jobs table.  
27 -  
28 - rails g delayed_job:upgrade  
29 - rake db:migrate  
30 -  
31 -That's it. Use [delayed_job as normal](http://github.com/collectiveidea/delayed_job).  
vendor/plugins/delayed_job_active_record/Rakefile
@@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
1 -# -*- encoding: utf-8 -*-  
2 -require "bundler/gem_helper"  
3 -Bundler::GemHelper.install_tasks  
4 -  
5 -require "rspec/core/rake_task"  
6 -  
7 -ADAPTERS = %w(mysql postgresql sqlite3)  
8 -  
9 -ADAPTERS.each do |adapter|  
10 - desc "Run RSpec code examples for #{adapter} adapter"  
11 - RSpec::Core::RakeTask.new(adapter => "#{adapter}:adapter")  
12 -  
13 - namespace adapter do  
14 - task :adapter do  
15 - ENV["ADAPTER"] = adapter  
16 - end  
17 - end  
18 -end  
19 -  
20 -task :coverage do  
21 - ENV["COVERAGE"] = "true"  
22 -end  
23 -  
24 -task :adapter do  
25 - ENV["ADAPTER"] = nil  
26 -end  
27 -  
28 -Rake::Task[:spec].enhance do  
29 - require "simplecov"  
30 - require "coveralls"  
31 -  
32 - Coveralls::SimpleCov::Formatter.new.format(SimpleCov.result)  
33 -end  
34 -  
35 -task default: ([:coverage] + ADAPTERS + [:adapter])  
vendor/plugins/delayed_job_active_record/delayed_job_active_record.gemspec
@@ -1,19 +0,0 @@ @@ -1,19 +0,0 @@
1 -# coding: utf-8  
2 -  
3 -Gem::Specification.new do |spec|  
4 - spec.add_dependency 'activerecord', ['>= 3.0', '< 4.1']  
5 - spec.add_dependency 'delayed_job', ['>= 3.0', '< 4.1']  
6 - spec.authors = ["Brian Ryckbost", "Matt Griffin", "Erik Michaels-Ober"]  
7 - spec.description = 'ActiveRecord backend for Delayed::Job, originally authored by Tobias Lütke'  
8 - spec.email = ['bryckbost@gmail.com', 'matt@griffinonline.org', 'sferik@gmail.com']  
9 - spec.files = %w(CONTRIBUTING.md LICENSE.md README.md Rakefile delayed_job_active_record.gemspec)  
10 - spec.files += Dir.glob("lib/**/*.rb")  
11 - spec.files += Dir.glob("spec/**/*")  
12 - spec.homepage = 'http://github.com/collectiveidea/delayed_job_active_record'  
13 - spec.licenses = ['MIT']  
14 - spec.name = 'delayed_job_active_record'  
15 - spec.require_paths = ['lib']  
16 - spec.summary = 'ActiveRecord backend for DelayedJob'  
17 - spec.test_files = Dir.glob("spec/**/*")  
18 - spec.version = '4.0.0'  
19 -end  
vendor/plugins/delayed_job_active_record/gemfiles/mysql/3-0.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcmysql-adapter'  
9 - gem 'jdbc-mysql'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'mysql', '~> 2.8.1'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.0.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/mysql/3-1.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcmysql-adapter'  
9 - gem 'jdbc-mysql'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'mysql', '~> 2.8.1'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.1.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/mysql/3-2.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcmysql-adapter'  
9 - gem 'jdbc-mysql'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'mysql', '~> 2.8.1'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.2.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/mysql/4-0.gemfile
@@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcmysql-adapter'  
9 - gem 'jdbc-mysql'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'mysql', '~> 2.9'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 4.0.0.beta"  
21 -  
22 - gem 'delayed_job', "~> 4.0.0.beta"  
23 -end  
24 -  
25 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/postgresql/3-0.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcpostgresql-adapter'  
9 - gem 'jdbc-postgres'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'pg'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.0.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/postgresql/3-1.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcpostgresql-adapter'  
9 - gem 'jdbc-postgres'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'pg'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.1.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/postgresql/3-2.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcpostgresql-adapter'  
9 - gem 'jdbc-postgres'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'pg'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.2.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/postgresql/4-0.gemfile
@@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'activerecord-jdbc-adapter'  
8 - gem 'activerecord-jdbcpostgresql-adapter'  
9 - gem 'jdbc-postgres'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'pg'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 4.0.0.beta"  
21 -  
22 - gem 'delayed_job', "~> 4.0.0.beta"  
23 -end  
24 -  
25 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/sqlite3/3-0.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'jruby-openssl'  
8 - gem 'activerecord-jdbc-adapter'  
9 - gem 'activerecord-jdbcsqlite3-adapter'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'sqlite3'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.0.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/sqlite3/3-1.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'jruby-openssl'  
8 - gem 'activerecord-jdbc-adapter'  
9 - gem 'activerecord-jdbcsqlite3-adapter'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'sqlite3'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.1.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/sqlite3/3-2.gemfile
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'jruby-openssl'  
8 - gem 'activerecord-jdbc-adapter'  
9 - gem 'activerecord-jdbcsqlite3-adapter'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'sqlite3'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 3.2.0"  
21 -end  
22 -  
23 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/sqlite3/4-0-protected_attributes.gemfile
@@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'jruby-openssl'  
8 - gem 'activerecord-jdbc-adapter'  
9 - gem 'activerecord-jdbcsqlite3-adapter'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'sqlite3'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11', :require => false  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 4.0.0.beta"  
21 - gem 'protected_attributes'  
22 -  
23 - gem 'delayed_job', "~> 4.0.0.beta", :require => false  
24 -end  
25 -  
26 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/gemfiles/sqlite3/4-0.gemfile
@@ -1,25 +0,0 @@ @@ -1,25 +0,0 @@
1 -source 'https://rubygems.org'  
2 -  
3 -gem 'rake'  
4 -  
5 -group :test do  
6 - platforms :jruby do  
7 - gem 'jruby-openssl'  
8 - gem 'activerecord-jdbc-adapter'  
9 - gem 'activerecord-jdbcsqlite3-adapter'  
10 - end  
11 -  
12 - platforms :ruby, :mswin, :mingw do  
13 - gem 'sqlite3'  
14 - end  
15 -  
16 - gem 'coveralls', :require => false  
17 - gem 'rspec', '>= 2.11'  
18 - gem 'simplecov', :require => false  
19 -  
20 - gem 'activerecord', "~> 4.0.0.beta"  
21 -  
22 - gem 'delayed_job', "~> 4.0.0.beta"  
23 -end  
24 -  
25 -gemspec :path => "../../"  
vendor/plugins/delayed_job_active_record/lib/delayed/backend/active_record.rb
@@ -1,111 +0,0 @@ @@ -1,111 +0,0 @@
1 -require 'active_record/version'  
2 -module Delayed  
3 - module Backend  
4 - module ActiveRecord  
5 - # A job object that is persisted to the database.  
6 - # Contains the work object as a YAML field.  
7 - class Job < ::ActiveRecord::Base  
8 - include Delayed::Backend::Base  
9 -  
10 - if ::ActiveRecord::VERSION::MAJOR < 4 || defined?(::ActiveRecord::MassAssignmentSecurity)  
11 - attr_accessible :priority, :run_at, :queue, :payload_object,  
12 - :failed_at, :locked_at, :locked_by, :handler  
13 - end  
14 -  
15 - scope :by_priority, lambda { order('priority ASC, run_at ASC') }  
16 -  
17 - before_save :set_default_run_at  
18 -  
19 - def self.set_delayed_job_table_name  
20 - delayed_job_table_name = "#{::ActiveRecord::Base.table_name_prefix}delayed_jobs"  
21 - self.table_name = delayed_job_table_name  
22 - end  
23 -  
24 - self.set_delayed_job_table_name  
25 -  
26 - def self.ready_to_run(worker_name, max_run_time)  
27 - where('(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name)  
28 - end  
29 -  
30 - def self.before_fork  
31 - ::ActiveRecord::Base.clear_all_connections!  
32 - end  
33 -  
34 - def self.after_fork  
35 - ::ActiveRecord::Base.establish_connection  
36 - end  
37 -  
38 - # When a worker is exiting, make sure we don't have any locked jobs.  
39 - def self.clear_locks!(worker_name)  
40 - where(:locked_by => worker_name).update_all(:locked_by => nil, :locked_at => nil)  
41 - end  
42 -  
43 - def self.reserve(worker, max_run_time = Worker.max_run_time)  
44 - # scope to filter to records that are "ready to run"  
45 - ready_scope = self.ready_to_run(worker.name, max_run_time)  
46 -  
47 - # scope to filter to the single next eligible job  
48 - ready_scope = ready_scope.where('priority >= ?', Worker.min_priority) if Worker.min_priority  
49 - ready_scope = ready_scope.where('priority <= ?', Worker.max_priority) if Worker.max_priority  
50 - ready_scope = ready_scope.where(:queue => Worker.queues) if Worker.queues.any?  
51 - ready_scope = ready_scope.by_priority  
52 -  
53 - now = self.db_time_now  
54 -  
55 - # Optimizations for faster lookups on some common databases  
56 - case self.connection.adapter_name  
57 - when "PostgreSQL"  
58 - # Custom SQL required for PostgreSQL because postgres does not support UPDATE...LIMIT  
59 - # This locks the single record 'FOR UPDATE' in the subquery (http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE)  
60 - # Note: active_record would attempt to generate UPDATE...LIMIT like sql for postgres if we use a .limit() filter, but it would not use  
61 - # 'FOR UPDATE' and we would have many locking conflicts  
62 - quoted_table_name = self.connection.quote_table_name(self.table_name)  
63 - subquery_sql = ready_scope.limit(1).lock(true).select('id').to_sql  
64 - reserved = self.find_by_sql(["UPDATE #{quoted_table_name} SET locked_at = ?, locked_by = ? WHERE id IN (#{subquery_sql}) RETURNING *", now, worker.name])  
65 - reserved[0]  
66 - when "MySQL", "Mysql2"  
67 - # This works on MySQL and possibly some other DBs that support UPDATE...LIMIT. It uses separate queries to lock and return the job  
68 - count = ready_scope.limit(1).update_all(:locked_at => now, :locked_by => worker.name)  
69 - return nil if count == 0  
70 - self.where(:locked_at => now, :locked_by => worker.name, :failed_at => nil).first  
71 - when "MSSQL", "Teradata"  
72 - # The MSSQL driver doesn't generate a limit clause when update_all is called directly  
73 - subsubquery_sql = ready_scope.limit(1).to_sql  
74 - # select("id") doesn't generate a subquery, so force a subquery  
75 - subquery_sql = "SELECT id FROM (#{subsubquery_sql}) AS x"  
76 - quoted_table_name = self.connection.quote_table_name(self.table_name)  
77 - sql = ["UPDATE #{quoted_table_name} SET locked_at = ?, locked_by = ? WHERE id IN (#{subquery_sql})", now, worker.name]  
78 - count = self.connection.execute(sanitize_sql(sql))  
79 - return nil if count == 0  
80 - # MSSQL JDBC doesn't support OUTPUT INSERTED.* for returning a result set, so query locked row  
81 - self.where(:locked_at => now, :locked_by => worker.name, :failed_at => nil).first  
82 - else  
83 - # This is our old fashion, tried and true, but slower lookup  
84 - ready_scope.limit(worker.read_ahead).detect do |job|  
85 - count = ready_scope.where(:id => job.id).update_all(:locked_at => now, :locked_by => worker.name)  
86 - count == 1 && job.reload  
87 - end  
88 - end  
89 - end  
90 -  
91 - # Get the current time (GMT or local depending on DB)  
92 - # Note: This does not ping the DB to get the time, so all your clients  
93 - # must have syncronized clocks.  
94 - def self.db_time_now  
95 - if Time.zone  
96 - Time.zone.now  
97 - elsif ::ActiveRecord::Base.default_timezone == :utc  
98 - Time.now.utc  
99 - else  
100 - Time.now  
101 - end  
102 - end  
103 -  
104 - def reload(*args)  
105 - reset  
106 - super  
107 - end  
108 - end  
109 - end  
110 - end  
111 -end  
vendor/plugins/delayed_job_active_record/lib/delayed_job_active_record.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -require 'active_record'  
2 -require 'delayed_job'  
3 -require 'delayed/backend/active_record'  
4 -  
5 -Delayed::Worker.backend = :active_record  
vendor/plugins/delayed_job_active_record/lib/generators/delayed_job/active_record_generator.rb
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -require 'generators/delayed_job/delayed_job_generator'  
2 -require 'generators/delayed_job/next_migration_version'  
3 -require 'rails/generators/migration'  
4 -require 'rails/generators/active_record'  
5 -  
6 -# Extend the DelayedJobGenerator so that it creates an AR migration  
7 -module DelayedJob  
8 - class ActiveRecordGenerator < ::DelayedJobGenerator  
9 - include Rails::Generators::Migration  
10 - extend NextMigrationVersion  
11 -  
12 - self.source_paths << File.join(File.dirname(__FILE__), 'templates')  
13 -  
14 - def create_migration_file  
15 - migration_template 'migration.rb', 'db/migrate/create_delayed_jobs.rb'  
16 - end  
17 -  
18 - def self.next_migration_number dirname  
19 - ActiveRecord::Generators::Base.next_migration_number dirname  
20 - end  
21 - end  
22 -end  
vendor/plugins/delayed_job_active_record/lib/generators/delayed_job/next_migration_version.rb
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -module DelayedJob  
2 - module NextMigrationVersion  
3 - # while methods have moved around this has been the implementation  
4 - # since ActiveRecord 3.0  
5 - def next_migration_number(dirname)  
6 - next_migration_number = current_migration_number(dirname) + 1  
7 - if ActiveRecord::Base.timestamped_migrations  
8 - [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max  
9 - else  
10 - "%.3d" % next_migration_number  
11 - end  
12 - end  
13 - end  
14 -end  
vendor/plugins/delayed_job_active_record/lib/generators/delayed_job/templates/migration.rb
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -class CreateDelayedJobs < ActiveRecord::Migration  
2 - def self.up  
3 - create_table :delayed_jobs, :force => true do |table|  
4 - table.integer :priority, :default => 0, :null => false # Allows some jobs to jump to the front of the queue  
5 - table.integer :attempts, :default => 0, :null => false # Provides for retries, but still fail eventually.  
6 - table.text :handler, :null => false # YAML-encoded string of the object that will do work  
7 - table.text :last_error # reason for last failure (See Note below)  
8 - table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.  
9 - table.datetime :locked_at # Set when a client is working on this object  
10 - table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)  
11 - table.string :locked_by # Who is working on this object (if locked)  
12 - table.string :queue # The name of the queue this job is in  
13 - table.timestamps  
14 - end  
15 -  
16 - add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'  
17 - end  
18 -  
19 - def self.down  
20 - drop_table :delayed_jobs  
21 - end  
22 -end  
vendor/plugins/delayed_job_active_record/lib/generators/delayed_job/templates/upgrade_migration.rb
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 -class AddQueueToDelayedJobs < ActiveRecord::Migration  
2 - def self.up  
3 - add_column :delayed_jobs, :queue, :string  
4 - end  
5 -  
6 - def self.down  
7 - remove_column :delayed_jobs, :queue  
8 - end  
9 -end  
vendor/plugins/delayed_job_active_record/lib/generators/delayed_job/upgrade_generator.rb
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -require 'generators/delayed_job/delayed_job_generator'  
2 -require 'generators/delayed_job/next_migration_version'  
3 -require 'rails/generators/migration'  
4 -require 'rails/generators/active_record'  
5 -  
6 -# Extend the DelayedJobGenerator so that it creates an AR migration  
7 -module DelayedJob  
8 - class UpgradeGenerator < ::DelayedJobGenerator  
9 - include Rails::Generators::Migration  
10 - extend NextMigrationVersion  
11 -  
12 - self.source_paths << File.join(File.dirname(__FILE__), 'templates')  
13 -  
14 - def create_migration_file  
15 - migration_template 'upgrade_migration.rb', 'db/migrate/add_queue_to_delayed_jobs.rb'  
16 - end  
17 -  
18 - def self.next_migration_number dirname  
19 - ActiveRecord::Generators::Base.next_migration_number dirname  
20 - end  
21 - end  
22 -end  
vendor/plugins/delayed_job_active_record/spec/database.yml
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -mysql:  
2 - adapter: mysql  
3 - database: delayed_job_test  
4 - username: root  
5 - encoding: utf8  
6 -  
7 -postgresql:  
8 - adapter: postgresql  
9 - database: delayed_job_test  
10 - username: postgres  
11 -  
12 -sqlite3:  
13 - adapter: sqlite3  
14 - database: ":memory:"  
vendor/plugins/delayed_job_active_record/spec/delayed/backend/active_record_spec.rb
@@ -1,81 +0,0 @@ @@ -1,81 +0,0 @@
1 -require 'helper'  
2 -require 'delayed/backend/active_record'  
3 -  
4 -describe Delayed::Backend::ActiveRecord::Job do  
5 - it_behaves_like 'a delayed_job backend'  
6 -  
7 - context "db_time_now" do  
8 - after do  
9 - Time.zone = nil  
10 - ActiveRecord::Base.default_timezone = :local  
11 - end  
12 -  
13 - it "returns time in current time zone if set" do  
14 - Time.zone = 'Eastern Time (US & Canada)'  
15 - expect(%(EST EDT)).to include(Delayed::Job.db_time_now.zone)  
16 - end  
17 -  
18 - it "returns UTC time if that is the AR default" do  
19 - Time.zone = nil  
20 - ActiveRecord::Base.default_timezone = :utc  
21 - expect(Delayed::Backend::ActiveRecord::Job.db_time_now.zone).to eq 'UTC'  
22 - end  
23 -  
24 - it "returns local time if that is the AR default" do  
25 - Time.zone = 'Central Time (US & Canada)'  
26 - ActiveRecord::Base.default_timezone = :local  
27 - expect(%w(CST CDT)).to include(Delayed::Backend::ActiveRecord::Job.db_time_now.zone)  
28 - end  
29 - end  
30 -  
31 - describe "after_fork" do  
32 - it "calls reconnect on the connection" do  
33 - ActiveRecord::Base.should_receive(:establish_connection)  
34 - Delayed::Backend::ActiveRecord::Job.after_fork  
35 - end  
36 - end  
37 -  
38 - describe "enqueue" do  
39 - it "allows enqueue hook to modify job at DB level" do  
40 - later = described_class.db_time_now + 20.minutes  
41 - job = Delayed::Backend::ActiveRecord::Job.enqueue :payload_object => EnqueueJobMod.new  
42 - expect(Delayed::Backend::ActiveRecord::Job.find(job.id).run_at).to be_within(1).of(later)  
43 - end  
44 - end  
45 -  
46 - if ::ActiveRecord::VERSION::MAJOR < 4 || defined?(::ActiveRecord::MassAssignmentSecurity)  
47 - context "ActiveRecord::Base.send(:attr_accessible, nil)" do  
48 - before do  
49 - Delayed::Backend::ActiveRecord::Job.send(:attr_accessible, nil)  
50 - end  
51 -  
52 - after do  
53 - Delayed::Backend::ActiveRecord::Job.send(:attr_accessible, *Delayed::Backend::ActiveRecord::Job.new.attributes.keys)  
54 - end  
55 -  
56 - it "is still accessible" do  
57 - job = Delayed::Backend::ActiveRecord::Job.enqueue :payload_object => EnqueueJobMod.new  
58 - expect(Delayed::Backend::ActiveRecord::Job.find(job.id).handler).to_not be_blank  
59 - end  
60 - end  
61 - end  
62 -  
63 - context "ActiveRecord::Base.table_name_prefix" do  
64 - it "when prefix is not set, use 'delayed_jobs' as table name" do  
65 - ::ActiveRecord::Base.table_name_prefix = nil  
66 - Delayed::Backend::ActiveRecord::Job.set_delayed_job_table_name  
67 -  
68 - expect(Delayed::Backend::ActiveRecord::Job.table_name).to eq 'delayed_jobs'  
69 - end  
70 -  
71 - it "when prefix is set, prepend it before default table name" do  
72 - ::ActiveRecord::Base.table_name_prefix = 'custom_'  
73 - Delayed::Backend::ActiveRecord::Job.set_delayed_job_table_name  
74 -  
75 - expect(Delayed::Backend::ActiveRecord::Job.table_name).to eq 'custom_delayed_jobs'  
76 -  
77 - ::ActiveRecord::Base.table_name_prefix = nil  
78 - Delayed::Backend::ActiveRecord::Job.set_delayed_job_table_name  
79 - end  
80 - end  
81 -end  
vendor/plugins/delayed_job_active_record/spec/delayed/serialization/active_record_spec.rb
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -require 'helper'  
2 -  
3 -describe ActiveRecord do  
4 - it "loads classes with non-default primary key" do  
5 - expect {  
6 - YAML.load(Story.create.to_yaml)  
7 - }.not_to raise_error  
8 - end  
9 -  
10 - it "loads classes even if not in default scope" do  
11 - expect {  
12 - YAML.load(Story.create(:scoped => false).to_yaml)  
13 - }.not_to raise_error  
14 - end  
15 -end  
vendor/plugins/delayed_job_active_record/spec/helper.rb
@@ -1,69 +0,0 @@ @@ -1,69 +0,0 @@
1 -require 'simplecov'  
2 -require 'coveralls'  
3 -  
4 -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[  
5 - SimpleCov::Formatter::HTMLFormatter,  
6 - Coveralls::SimpleCov::Formatter  
7 -]  
8 -SimpleCov.start  
9 -  
10 -require 'logger'  
11 -require 'rspec'  
12 -  
13 -begin  
14 - require 'protected_attributes'  
15 -rescue LoadError  
16 -end  
17 -require 'delayed_job_active_record'  
18 -require 'delayed/backend/shared_spec'  
19 -  
20 -Delayed::Worker.logger = Logger.new('/tmp/dj.log')  
21 -ENV['RAILS_ENV'] = 'test'  
22 -  
23 -db_adapter, gemfile = ENV["ADAPTER"], ENV["BUNDLE_GEMFILE"]  
24 -db_adapter ||= gemfile && gemfile[%r(gemfiles/(.*?)/)] && $1  
25 -db_adapter ||= 'sqlite3'  
26 -  
27 -config = YAML.load(File.read('spec/database.yml'))  
28 -ActiveRecord::Base.establish_connection config[db_adapter]  
29 -ActiveRecord::Base.logger = Delayed::Worker.logger  
30 -ActiveRecord::Migration.verbose = false  
31 -  
32 -ActiveRecord::Schema.define do  
33 - create_table :delayed_jobs, :force => true do |table|  
34 - table.integer :priority, :default => 0  
35 - table.integer :attempts, :default => 0  
36 - table.text :handler  
37 - table.text :last_error  
38 - table.datetime :run_at  
39 - table.datetime :locked_at  
40 - table.datetime :failed_at  
41 - table.string :locked_by  
42 - table.string :queue  
43 - table.timestamps  
44 - end  
45 -  
46 - add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'  
47 -  
48 - create_table :stories, :primary_key => :story_id, :force => true do |table|  
49 - table.string :text  
50 - table.boolean :scoped, :default => true  
51 - end  
52 -end  
53 -  
54 -# Purely useful for test cases...  
55 -class Story < ActiveRecord::Base  
56 - if ::ActiveRecord::VERSION::MAJOR < 4 && ActiveRecord::VERSION::MINOR < 2  
57 - set_primary_key :story_id  
58 - else  
59 - self.primary_key = :story_id  
60 - end  
61 - def tell; text; end  
62 - def whatever(n, _); tell*n; end  
63 - default_scope { where(:scoped => true) }  
64 -  
65 - handle_asynchronously :whatever  
66 -end  
67 -  
68 -# Add this directory so the ActiveSupport autoloading works  
69 -ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__)  
vendor/plugins/monkey_patches/will_paginate_check_finder_sql/init.rb
@@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
1 -# monkey patch to fix WillPaginate bug  
2 -# this was solved in will_paginate 3.x.pre, then remove this patch when upgrade to it  
3 -#  
4 -# http://sod.lighthouseapp.com/projects/17958/tickets/120-paginate-association-with-finder_sql-raises-typeerror  
5 -require 'will_paginate'  
6 -  
7 -WillPaginate::Finder::ClassMethods.module_eval do  
8 - def paginate_with_finder_sql(*args)  
9 - if respond_to?(:proxy_reflection) && !proxy_reflection.options[:finder_sql].nil?  
10 - # note: paginate_by_sql ignores the blocks. So don't pass the block  
11 - paginate_by_sql(@finder_sql, args.extract_options!)  
12 - else  
13 - paginate_without_finder_sql(*args)  
14 - end  
15 - end  
16 - # patch to deal with the custom_sql scenario  
17 - alias_method_chain :paginate, :finder_sql  
18 -end  
vendor/plugins/pothoven-attachment_fu/CHANGELOG
@@ -1,84 +0,0 @@ @@ -1,84 +0,0 @@
1 -* Aug 22, 2013 *  
2 -* Added cache-control header option and Ruby 1.9 fix for S3 from tricycle  
3 -  
4 -* Aug 21, 2013 *  
5 -* Added S3 :encrypted_storage option support from cschulte22  
6 -  
7 -* Jul 5, 2013  
8 -* Pull in changes from lchimonji10 to reformat README to RDoc format  
9 -  
10 -* Apr 10, 2013 *  
11 -* Ruby 2 compatibility fix  
12 -* Removed some lingering occurrences of RAILS_ROOT and RAILS_ENV  
13 -* clean up of gemspec file  
14 -* no longer package unnecessary files like the test files  
15 -  
16 -* Mar 12, 2013 *  
17 -* Pull in changes from https://github.com/aalong/attachment_fu to use Ruby 1.9.2 Tempfile naming strategy to fix conflicts with Sprockets (see https://github.com/aalong/attachment_fu/commit/938ec3b8597fbf82b1de8c98de12c4688463450a)  
18 -  
19 -* Feb 19, 2013 *  
20 -* Pull in changes from https://github.com/itkin/attachment_fu fork to fix mini magick  
21 -  
22 -* Nov 15, 2012 *  
23 -* Removed 'crop:' option as already included when prefixing geometry with a 'c'. Add note to docs.  
24 -* Added option to sharpen resized images ':sharpen_on_resize'  
25 -  
26 -* Oct 26, 2012 *  
27 -* Merged with https://github.com/tdd/attachment_fu fork to include GEM support for use in Rails 3.2, and bumped version to 3.2.x to indicate Rails 3.2 support.  
28 -  
29 -* Oct 25, 2012 *  
30 -* Fix to support Ruby 1.9.3  
31 -* Image cropping support (append 'crop:' to desired file size when resizing)  
32 -  
33 -* Mar 15, 2010 *  
34 -* Added a symbol syntax for parent-type-based size spec: calls the corresponding method on the current asset instance to  
35 - get a Hash of required thumbnails. Lets us dynamically specify what would otherwise be hard-coded, which is useful  
36 - when the set of thumbnails for a given parent type varies depending on the usage context.  
37 -  
38 -* Aug 6, 2009 *  
39 -* JPEG quality control finalized across processors (although CoreImage applies it in a rather fuzzy-logic way), with tests.  
40 -  
41 -* Aug 4, 2009 *  
42 -* Supports the :aspect/'!' geometry flag in all processors  
43 - (thanks to http://www.deepcalm.com/writing/cropped-thumbnails-in-attachment_fu-using-imagescience)  
44 -* JPEG quality control on thumbnailing/resizing (still buggy on Rmagick/MiniMagick though).  
45 -* Moves from GIF to PNG regardless of the source file extension's case (used to require lowercase)  
46 -* Auto-orients image (if EXIF suggests it) prior to processing with RMagickProcessor  
47 -* Fixes non-image upload tests (both regular files and Merb files)  
48 -* Fixes obsolete failures on RMagick tests (aspect_ratio tested but not initialized anymore due to new callback architecture  
49 -  
50 -* Apr 17 2008 *  
51 -* amazon_s3.yml is now passed through ERB before being passed to AWS::S3 [François Beausoleil]  
52 -  
53 -* Mar 22 2008 *  
54 -* Some tweaks to support Rails 2.0 and Rails 2.1 due to ActiveSupport::Callback changes.  
55 - Thanks to http://blog.methodmissing.com/2008/1/19/edge-callback-refactorings-attachment_fu/  
56 -  
57 -* Feb. 26, 2008 *  
58 -* remove breakpoint from test_helper, makes test suite crazy (at least Rails 2+) [Rob Sanheim]  
59 -* make S3 test really optional [Rob Sanheim]  
60 -  
61 -* Nov 27, 2007 *  
62 -* Handle properly ImageScience thumbnails resized from a gif file [Matt Aimonetti]  
63 -* Save thumbnails file size properly when using ImageScience [Matt Aimonetti]  
64 -* fixed s3 config file loading with latest versions of Rails [Matt Aimonetti]  
65 -  
66 -* April 2, 2007 *  
67 -  
68 -* don't copy the #full_filename to the default #temp_paths array if it doesn't exist  
69 -* add default ID partitioning for attachments  
70 -* add #binmode call to Tempfile (note: ruby should be doing this!) [Eric Beland]  
71 -* Check for current type of :thumbnails option.  
72 -* allow customization of the S3 configuration file path with the :s3_config_path option.  
73 -* Don't try to remove thumbnails if there aren't any. Closes #3 [ben stiglitz]  
74 -  
75 -* BC * (before changelog)  
76 -  
77 -* add default #temp_paths entry [mattly]  
78 -* add MiniMagick support to attachment_fu [Isacc]  
79 -* update #destroy_file to clear out any empty directories too [carlivar]  
80 -* fix references to S3Backend module [Hunter Hillegas]  
81 -* make #current_data public with db_file and s3 backends [ebryn]  
82 -* oops, actually svn add the files for s3 backend. [Jeffrey Hardy]  
83 -* experimental s3 support, egad, no tests.... [Jeffrey Hardy]  
84 -* doh, fix a few bad references to ActsAsAttachment [sixty4bit]  
vendor/plugins/pothoven-attachment_fu/Gemfile
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -source 'http://rubygems.org'  
2 -  
3 -  
4 -group :test, :development do  
5 - gem 'rails', '~> 3.2'  
6 - gem 'sqlite3'  
7 - gem 'pothoven-attachment_fu', :path => '.'  
8 - gem 'rmagick'  
9 - gem 'core_image'  
10 - gem 'mini_magick'  
11 - gem 'aws-s3', :require => 'aws/s3'  
12 - gem 'test-unit'  
13 -end  
vendor/plugins/pothoven-attachment_fu/Gemfile.lock
@@ -1,109 +0,0 @@ @@ -1,109 +0,0 @@
1 -PATH  
2 - remote: .  
3 - specs:  
4 - pothoven-attachment_fu (3.2.10)  
5 -  
6 -GEM  
7 - remote: http://rubygems.org/  
8 - specs:  
9 - actionmailer (3.2.14)  
10 - actionpack (= 3.2.14)  
11 - mail (~> 2.5.4)  
12 - actionpack (3.2.14)  
13 - activemodel (= 3.2.14)  
14 - activesupport (= 3.2.14)  
15 - builder (~> 3.0.0)  
16 - erubis (~> 2.7.0)  
17 - journey (~> 1.0.4)  
18 - rack (~> 1.4.5)  
19 - rack-cache (~> 1.2)  
20 - rack-test (~> 0.6.1)  
21 - sprockets (~> 2.2.1)  
22 - activemodel (3.2.14)  
23 - activesupport (= 3.2.14)  
24 - builder (~> 3.0.0)  
25 - activerecord (3.2.14)  
26 - activemodel (= 3.2.14)  
27 - activesupport (= 3.2.14)  
28 - arel (~> 3.0.2)  
29 - tzinfo (~> 0.3.29)  
30 - activeresource (3.2.14)  
31 - activemodel (= 3.2.14)  
32 - activesupport (= 3.2.14)  
33 - activesupport (3.2.14)  
34 - i18n (~> 0.6, >= 0.6.4)  
35 - multi_json (~> 1.0)  
36 - arel (3.0.2)  
37 - aws-s3 (0.6.3)  
38 - builder  
39 - mime-types  
40 - xml-simple  
41 - builder (3.0.4)  
42 - core_image (0.0.3.5)  
43 - erubis (2.7.0)  
44 - hike (1.2.3)  
45 - i18n (0.6.5)  
46 - journey (1.0.4)  
47 - json (1.8.0)  
48 - mail (2.5.4)  
49 - mime-types (~> 1.16)  
50 - treetop (~> 1.4.8)  
51 - mime-types (1.24)  
52 - mini_magick (3.6.0)  
53 - subexec (~> 0.2.1)  
54 - multi_json (1.7.9)  
55 - polyglot (0.3.3)  
56 - rack (1.4.5)  
57 - rack-cache (1.2)  
58 - rack (>= 0.4)  
59 - rack-ssl (1.3.3)  
60 - rack  
61 - rack-test (0.6.2)  
62 - rack (>= 1.0)  
63 - rails (3.2.14)  
64 - actionmailer (= 3.2.14)  
65 - actionpack (= 3.2.14)  
66 - activerecord (= 3.2.14)  
67 - activeresource (= 3.2.14)  
68 - activesupport (= 3.2.14)  
69 - bundler (~> 1.0)  
70 - railties (= 3.2.14)  
71 - railties (3.2.14)  
72 - actionpack (= 3.2.14)  
73 - activesupport (= 3.2.14)  
74 - rack-ssl (~> 1.3.2)  
75 - rake (>= 0.8.7)  
76 - rdoc (~> 3.4)  
77 - thor (>= 0.14.6, < 2.0)  
78 - rake (10.1.0)  
79 - rdoc (3.12.2)  
80 - json (~> 1.4)  
81 - rmagick (2.13.2)  
82 - sprockets (2.2.2)  
83 - hike (~> 1.2)  
84 - multi_json (~> 1.0)  
85 - rack (~> 1.0)  
86 - tilt (~> 1.1, != 1.3.0)  
87 - sqlite3 (1.3.8)  
88 - subexec (0.2.3)  
89 - test-unit (2.5.5)  
90 - thor (0.18.1)  
91 - tilt (1.4.1)  
92 - treetop (1.4.15)  
93 - polyglot  
94 - polyglot (>= 0.3.1)  
95 - tzinfo (0.3.37)  
96 - xml-simple (1.1.2)  
97 -  
98 -PLATFORMS  
99 - ruby  
100 -  
101 -DEPENDENCIES  
102 - aws-s3  
103 - core_image  
104 - mini_magick  
105 - pothoven-attachment_fu!  
106 - rails (~> 3.2)  
107 - rmagick  
108 - sqlite3  
109 - test-unit  
vendor/plugins/pothoven-attachment_fu/LICENSE
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -Copyright (c) 2009 rick olson  
2 -  
3 -Permission is hereby granted, free of charge, to any person obtaining  
4 -a copy of this software and associated documentation files (the  
5 -"Software"), to deal in the Software without restriction, including  
6 -without limitation the rights to use, copy, modify, merge, publish,  
7 -distribute, sublicense, and/or sell copies of the Software, and to  
8 -permit persons to whom the Software is furnished to do so, subject to  
9 -the following conditions:  
10 -  
11 -The above copyright notice and this permission notice shall be  
12 -included in all copies or substantial portions of the Software.  
13 -  
14 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  
15 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
16 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND  
17 -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE  
18 -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION  
19 -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
20 -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
vendor/plugins/pothoven-attachment_fu/README
@@ -1,193 +0,0 @@ @@ -1,193 +0,0 @@
1 -attachment-fu  
2 -=============  
3 -  
4 -attachment_fu is a plugin by Rick Olson (aka technoweenie <http://techno-weenie.net>) and is the successor to acts_as_attachment. To get a basic run-through of its capabilities, check out Mike Clark's tutorial <http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu>.  
5 -  
6 -  
7 -attachment_fu functionality  
8 -===========================  
9 -  
10 -attachment_fu facilitates file uploads in Ruby on Rails. There are a few storage options for the actual file data, but the plugin always at a minimum stores metadata for each file in the database.  
11 -  
12 -There are four storage options for files uploaded through attachment_fu:  
13 - File system  
14 - Database file  
15 - Amazon S3  
16 - Rackspace (Mosso) Cloud Files  
17 -  
18 -Each method of storage many options associated with it that will be covered in the following section. Something to note, however, is that the Amazon S3 storage requires you to modify config/amazon_s3.yml, the Rackspace Cloud Files storage requires you to modify config/rackspace_cloudfiles.yml, and the Database file storage requires an extra table.  
19 -  
20 -  
21 -attachment_fu models  
22 -====================  
23 -  
24 -For all three of these storage options a table of metadata is required. This table will contain information about the file (hence the 'meta') and its location. This table has no restrictions on naming, unlike the extra table required for database storage, which must have a table name of db_files (and by convention a model of DbFile).  
25 -  
26 -In the model there are two methods made available by this plugins: has_attachment and validates_as_attachment.  
27 -  
28 -has_attachment(options = {})  
29 - This method accepts the options in a hash:  
30 - :content_type # Allowed content types.  
31 - # Allows all by default. Use :image to allow all standard image types.  
32 - :min_size # Minimum size allowed.  
33 - # 1 byte is the default.  
34 - :max_size # Maximum size allowed.  
35 - # 1.megabyte is the default.  
36 - :size # Range of sizes allowed.  
37 - # (1..1.megabyte) is the default. This overrides the :min_size and :max_size options.  
38 - :resize_to # Used by RMagick to resize images.  
39 - # Pass either an array of width/height, or a geometry string.  
40 - :thumbnails # Specifies a set of thumbnails to generate.  
41 - # This accepts a hash of filename suffixes and RMagick resizing options.  
42 - # This option need only be included if you want thumbnailing.  
43 - :thumbnail_class # Set which model class to use for thumbnails.  
44 - # This current attachment class is used by default.  
45 - :path_prefix # Path to store the uploaded files in.  
46 - # Uses public/#{table_name} by default for the filesystem, and just #{table_name} for the S3 and Cloud Files backend.  
47 - # Setting this sets the :storage to :file_system.  
48 - :partition # Whether to partiton files in directories like /0000/0001/image.jpg. Default is true. Only applicable to the :file_system backend.  
49 - :storage # Specifies the storage system to use..  
50 - # Defaults to :db_file. Options are :file_system, :db_file, :s3, and :cloud_files.  
51 - :cloudfront # If using S3 for storage, this option allows for serving the files via Amazon CloudFront.  
52 - # Defaults to false.  
53 - :processor # Sets the image processor to use for resizing of the attached image.  
54 - # Options include ImageScience, Rmagick, and MiniMagick. Default is whatever is installed.  
55 - :uuid_primary_key # If your model's primary key is a 128-bit UUID in hexadecimal format, then set this to true.  
56 - :association_options # attachment_fu automatically defines associations with thumbnails with has_many and belongs_to. If there are any additional options that you want to pass to these methods, then specify them here.  
57 -  
58 -  
59 - Examples:  
60 - has_attachment :max_size => 1.kilobyte  
61 - has_attachment :size => 1.megabyte..2.megabytes  
62 - has_attachment :content_type => 'application/pdf'  
63 - has_attachment :content_type => ['application/pdf', 'application/msword', 'text/plain']  
64 - has_attachment :content_type => :image, :resize_to => [50,50]  
65 - has_attachment :content_type => ['application/pdf', :image], :resize_to => 'x50'  
66 - has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }  
67 - has_attachment :storage => :file_system, :path_prefix => 'public/files'  
68 - has_attachment :storage => :file_system, :path_prefix => 'public/files',  
69 - :content_type => :image, :resize_to => [50,50], :partition => false  
70 - has_attachment :storage => :file_system, :path_prefix => 'public/files',  
71 - :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }  
72 - has_attachment :storage => :s3  
73 - has_attachment :store => :s3, :cloudfront => true  
74 - has_attachment :storage => :cloud_files  
75 -  
76 -validates_as_attachment  
77 - This method prevents files outside of the valid range (:min_size to :max_size, or the :size range) from being saved. It does not however, halt the upload of such files. They will be uploaded into memory regardless of size before validation.  
78 -  
79 - Example:  
80 - validates_as_attachment  
81 -  
82 -  
83 -attachment_fu migrations  
84 -========================  
85 -  
86 -Fields for attachment_fu metadata tables...  
87 - in general:  
88 - size, :integer # file size in bytes  
89 - content_type, :string # mime type, ex: application/mp3  
90 - filename, :string # sanitized filename  
91 - that reference images:  
92 - height, :integer # in pixels  
93 - width, :integer # in pixels  
94 - that reference images that will be thumbnailed:  
95 - parent_id, :integer # id of parent image (on the same table, a self-referencing foreign-key).  
96 - # Only populated if the current object is a thumbnail.  
97 - thumbnail, :string # the 'type' of thumbnail this attachment record describes.  
98 - # Only populated if the current object is a thumbnail.  
99 - # Usage:  
100 - # [ In Model 'Avatar' ]  
101 - # has_attachment :content_type => :image,  
102 - # :storage => :file_system,  
103 - # :max_size => 500.kilobytes,  
104 - # :resize_to => '320x200>',  
105 - # :thumbnails => { :small => '10x10>',  
106 - # :thumb => '100x100>' }  
107 - # [ Elsewhere ]  
108 - # @user.avatar.thumbnails.first.thumbnail #=> 'small'  
109 - that reference files stored in the database (:db_file):  
110 - db_file_id, :integer # id of the file in the database (foreign key)  
111 -  
112 -Field for attachment_fu db_files table:  
113 - data, :binary # binary file data, for use in database file storage  
114 -  
115 -  
116 -attachment_fu views  
117 -===================  
118 -  
119 -There are two main views tasks that will be directly affected by attachment_fu: upload forms and displaying uploaded images.  
120 -  
121 -There are two parts of the upload form that differ from typical usage.  
122 - 1. Include ':multipart => true' in the html options of the form_for tag.  
123 - Example:  
124 - <% form_for(:attachment_metadata, :url => { :action => "create" }, :html => { :multipart => true }) do |form| %>  
125 -  
126 - 2. Use the file_field helper with :uploaded_data as the field name.  
127 - Example:  
128 - <%= form.file_field :uploaded_data %>  
129 -  
130 -Displaying uploaded images is made easy by the public_filename method of the ActiveRecord attachment objects using file system, s3, and Cloud Files storage.  
131 -  
132 -public_filename(thumbnail = nil)  
133 - Returns the public path to the file. If a thumbnail prefix is specified it will return the public file path to the corresponding thumbnail.  
134 - Examples:  
135 - attachment_obj.public_filename #=> /attachments/2/file.jpg  
136 - attachment_obj.public_filename(:thumb) #=> /attachments/2/file_thumb.jpg  
137 - attachment_obj.public_filename(:small) #=> /attachments/2/file_small.jpg  
138 -  
139 -When serving files from database storage, doing more than simply downloading the file is beyond the scope of this document.  
140 -  
141 -  
142 -attachment_fu controllers  
143 -=========================  
144 -  
145 -There are two considerations to take into account when using attachment_fu in controllers.  
146 -  
147 -The first is when the files have no publicly accessible path and need to be downloaded through an action.  
148 -  
149 -Example:  
150 - def readme  
151 - send_file '/path/to/readme.txt', :type => 'plain/text', :disposition => 'inline'  
152 - end  
153 -  
154 -See the possible values for send_file for reference.  
155 -  
156 -  
157 -The second is when saving the file when submitted from a form.  
158 -Example in view:  
159 - <%= form.file_field :attachable, :uploaded_data %>  
160 -  
161 -Example in controller:  
162 - def create  
163 - @attachable_file = AttachmentMetadataModel.new(params[:attachable])  
164 - if @attachable_file.save  
165 - flash[:notice] = 'Attachment was successfully created.'  
166 - redirect_to attachable_url(@attachable_file)  
167 - else  
168 - render :action => :new  
169 - end  
170 - end  
171 -  
172 -attachement_fu scripting  
173 -====================================  
174 -  
175 -You may wish to import a large number of images or attachments.  
176 -The following example shows how to upload a file from a script.  
177 -  
178 -#!/usr/bin/env ./script/runner  
179 -  
180 -# required to use ActionController::TestUploadedFile  
181 -require 'action_controller'  
182 -require 'action_controller/test_process.rb'  
183 -  
184 -path = "./public/images/x.jpg"  
185 -  
186 -# mimetype is a string like "image/jpeg". One way to get the mimetype for a given file on a UNIX system  
187 -# mimetype = `file -ib #{path}`.gsub(/\n/,"")  
188 -  
189 -mimetype = "image/jpeg"  
190 -  
191 -# This will "upload" the file at path and create the new model.  
192 -@attachable = AttachmentMetadataModel.new(:uploaded_data => ActionController::TestUploadedFile.new(path, mimetype))  
193 -@attachable.save  
vendor/plugins/pothoven-attachment_fu/README.rdoc
@@ -1,352 +0,0 @@ @@ -1,352 +0,0 @@
1 -= attachment-fu  
2 -  
3 -attachment_fu is a plugin by Rick Olson (aka technoweenie  
4 -http://techno-weenie.net) and is the successor to acts_as_attachment. To get a  
5 -basic run-through of its capabilities, check out {Mike Clark's  
6 -tutorial}[http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu].  
7 -  
8 -= attachment_fu functionality  
9 -  
10 -attachment_fu facilitates file uploads in Ruby on Rails. There are a few  
11 -storage options for the actual file data, but the plugin always at a minimum  
12 -stores metadata for each file in the database.  
13 -  
14 -There are four storage options for files uploaded through attachment_fu:  
15 -  
16 -* File system  
17 -* Database file  
18 -* Amazon S3  
19 -* Rackspace (Mosso) Cloud Files  
20 -  
21 -Each method of storage many options associated with it that will be covered in  
22 -the following section. Something to note, however, is that the Amazon S3 storage  
23 -requires you to modify +config/amazon_s3.yml+, the Rackspace Cloud Files storage  
24 -requires you to modify +config/rackspace_cloudfiles.yml+, and the Database file  
25 -storage requires an extra table.  
26 -  
27 -= attachment_fu models  
28 -  
29 -For all three of these storage options a table of metadata is required. This  
30 -table will contain information about the file (hence the 'meta') and its  
31 -location. This table has no restrictions on naming, unlike the extra table  
32 -required for database storage, which must have a table name of +db_files+ (and  
33 -by convention a model of +DbFile+).  
34 -  
35 -Two methods are available to models: +has_attachment+ and  
36 -+validates_as_attachment+.  
37 -  
38 -== has_attachment(options = {})  
39 -  
40 -This method accepts the options in a hash:  
41 -  
42 -[:content_type]  
43 - Allowed content types.  
44 -  
45 - By default, all content types are allowed. Use +:image+ to allow all  
46 - standard image types.  
47 -  
48 -[:min_size]  
49 - Minimum file size.  
50 -  
51 - By default, set to +1.byte+.  
52 -  
53 -[:max_size]  
54 - Maximum file size.  
55 -  
56 - By default, set to +1.megabyte+.  
57 -  
58 -[:size]  
59 - Minimum and maximum file size.  
60 -  
61 - By default, set to +1..1.megabyte+. Overrides +:min_size+ and  
62 - +:max_size+.  
63 -  
64 -[:resize_to]  
65 - Used by RMagick.  
66 -  
67 - Tells RMagick how to resize images. Pass either an array specifying  
68 - width and height or a geometry string. Prefixing the geometry string  
69 - with a 'c' will crop the image to the specified size.  
70 -  
71 -[:sharpen_on_resize]  
72 - Used by RMagick.  
73 -  
74 - If set to true, images are sharpened after being resized.  
75 -  
76 -[:thumbnails]  
77 - A set of thumbnails to generate.  
78 -  
79 - This accepts a hash of filename suffixes and RMagick resizing options. This  
80 - option need only be included if you want thumbnailing.  
81 -  
82 - If you have a polymorphic parent relationship, you can provide  
83 - parent-type-specific thumbnail settings by using a pair with the type string  
84 - as key and a Hash of thumbnail definitions, or a method symbol, as value.  
85 - The method symbol will call the named method in order to get a  
86 - dynamically-built Hash of thumbnail definitions, which gives you full  
87 - flexibility. AttachmentFu automatically detects your first polymorphic  
88 - +belongs_to+ relationship.  
89 -  
90 -[:thumbnail_class]  
91 - Which model class to use for thumbnails.  
92 -  
93 - By default, the current attachment class is used.  
94 -  
95 -[:jpeg_quality]  
96 - JPEG quality settings for thumbnail resizes.  
97 -  
98 - Arguments can be in multiple formats:  
99 -  
100 - * Integer from 0 (basically crap) to 100 (basically lossless, fat files).  
101 -  
102 - * When relying on tdd-image_science, you can also use one of its +JPEG_xxx+  
103 - constants for predefined ratios/settings.  
104 -  
105 - * You can also use a Hash, with keys being either thumbnail symbols (I  
106 - repeat: _symbols_) or surface boundaries. A surface boundary is a string  
107 - starting with either '<' or '>=', followed by a number of pixels. This  
108 - lets you specify per-thumbnail or per-general-thumbnail-"size" JPEG  
109 - qualities. (which can be useful when you have a _lot_ of thumbnail  
110 - options). Surface example: <code>{'<2000' => 90, '>=2000' => 75}</code>.  
111 -  
112 - Defaults vary depending on the processor (ImageScience: 100%,  
113 - Rmagick/MiniMagick/Gd2: 75%, CoreImage: auto-adjust). Note that only  
114 - tdd-image_science (available from GitHub) currently supports explicit JPEG  
115 - quality; the default image_science currently forces 100%.  
116 -  
117 -[:path_prefix]  
118 - Path to store the uploaded files in. Uses <code>public/#{table_name}</code>  
119 - by default for the filesystem, and just <code>#{table_name}</code> for the  
120 - S3 and Cloud Files backend. Setting this sets the +:storage+ to  
121 - +:file_system+.  
122 -  
123 -[:partition]  
124 - Whether to partiton files in directories like +/0000/0001/image.jpg+.  
125 - Default is true. Only applicable to the +:file_system+ backend.  
126 -  
127 -[:storage]  
128 - Specifies the storage system to use. Defaults to +:db_file+. Options are  
129 - +:file_system+, +:db_file+, +:s3+, and +:cloud_files+.  
130 -  
131 -[:cloudfront]  
132 - If using S3 for storage, this option allows for serving the files via Amazon  
133 - CloudFront. Defaults to false.  
134 -  
135 -[:processor]  
136 - Sets the image processor to use for resizing of the attached image. Options  
137 - include ImageScience, Rmagick, MiniMagick, Gd2 and CoreImage. Default is  
138 - whatever is installed.  
139 -  
140 -[:uuid_primary_key]  
141 - If your model's primary key is a 128-bit UUID in hexadecimal format, then  
142 - set this to true.  
143 -  
144 -[:association_options]  
145 - attachment_fu automatically defines associations with thumbnails with  
146 - +has_many+ and +belongs_to+. If there are any additional options that you  
147 - want to pass to these methods, then specify them here.  
148 -  
149 -Examples:  
150 -  
151 - has_attachment(content_type: 'application/pdf')  
152 - has_attachment(  
153 - content_type: ['application/pdf', 'application/msword', 'text/plain']  
154 - )  
155 - has_attachment(content_type: ['application/pdf', :image], resize_to: 'x50')  
156 - has_attachment(content_type: :image, resize_to: [50,50])  
157 - has_attachment(max_size: 1.kilobyte)  
158 - has_attachment(size: 1.megabyte..2.megabytes)  
159 - has_attachment(storage: :cloud_files)  
160 - has_attachment(storage: :file_system, path_prefix: 'public/files')  
161 - has_attachment(  
162 - storage: :file_system,  
163 - path_prefix: 'public/files',  
164 - content_type: :image,  
165 - resize_to: [50, 50],  
166 - partition: false  
167 - )  
168 - has_attachment(  
169 - storage: :file_system,  
170 - path_prefix: 'public/files',  
171 - thumbnails: {thumb: [50, 50], geometry: 'x50'}  
172 - )  
173 - has_attachment(storage: :s3)  
174 - has_attachment(store: :s3, cloudfront: true)  
175 - has_attachment(thumbnails: {thumb: [50, 50], geometry: 'x50'})  
176 -  
177 - # Let's say we have a polymorphic belongs_to, e.g. called 'imageable', where  
178 - # imageable_type (or whatever the :foreign_type option was set to) can be,  
179 - # among other things, 'Product', 'User' or 'Editorial', each of which should  
180 - # have extra thumbnails:  
181 -  
182 - has_attachment(thumbnails: {  
183 - editorials: {fullsize: '150x100>'},  
184 - geometry: 'x50',  
185 - products: {large_thumb: '169x169!', zoomed: '500x500>'},  
186 - thumb: [50, 50],  
187 - users: {avatar: '64x64!'}  
188 - })  
189 -  
190 - # JPEG qualities…  
191 -  
192 - has_attachment(jpeg_quality: 75)  
193 - has_attachment(jpeg_quality: 80 | ImageScience::JPEG_PROGRESSIVE)  
194 - has_attachment(  
195 - thumbnails: {thumb: [50, 50], geometry: 'x50'},  
196 - jpeg_quality: {'<2000' => 90, '>=2000' => 75}  
197 - )  
198 - has_attachment(  
199 - thumbnails: {thumb: [50, 50], geometry: 'x50'},  
200 - jpeg_quality: {nil => 75, thumb: 90, geometry: 90}  
201 - )  
202 -  
203 -== validates_as_attachment  
204 -  
205 -This method prevents files outside of the valid range (+:min_size+ to  
206 -+:max_size+, or the +:size+ range) from being saved. It does not however, halt  
207 -the upload of such files. They will be uploaded into memory regardless of size  
208 -before validation.  
209 -  
210 -To perform this validation, simply add +validates_as_attachment+ to your model.  
211 -  
212 -= attachment_fu migrations  
213 -  
214 -Fields for attachment_fu metadata tables…  
215 -  
216 -In general:  
217 -  
218 - size, :integer # file size in bytes  
219 - content_type, :string # mime type, ex: application/mp3  
220 - filename, :string # sanitized filename  
221 -  
222 -That reference images:  
223 -  
224 - height, :integer # in pixels  
225 - width, :integer # in pixels  
226 -  
227 -That reference images that will be thumbnailed:  
228 -  
229 - parent_id, :integer # id of parent image (on the same table, a  
230 - # self-referencing foreign-key). Only populated if  
231 - # the current object is a thumbnail.  
232 - thumbnail, :string # The type of thumbnail this attachment record  
233 - # describes. Only populated if the current object is  
234 - # a thumbnail. Example:  
235 - #  
236 - # (In Model 'Avatar')  
237 - # has_attachment(  
238 - # :content_type => :image,  
239 - # :storage => :file_system,  
240 - # :max_size => 500.kilobytes,  
241 - # :resize_to => '320x200>',  
242 - # :thumbnails => {  
243 - # :small => '10x10>',  
244 - # :thumb => '100x100>'  
245 - # }  
246 - # )  
247 - #  
248 - # (Elsewhere)  
249 - # @user.avatar.thumbnails.first.thumbnail # => 'small'  
250 - #  
251 - db_file_id, :integer # ID of the file in the database (foreign key) that  
252 - # reference files stored in the database (:db_file).  
253 -  
254 -Field for attachment_fu +db_files+ table:  
255 -  
256 - data, :binary # binary file data, for use in database file storage  
257 -  
258 -= attachment_fu views  
259 -  
260 -There are two main views tasks that will be directly affected by attachment_fu:  
261 -upload forms and displaying uploaded images.  
262 -  
263 -There are two parts of the upload form that differ from typical usage.  
264 -  
265 -1. Include <code>multipart: true</code> in the html options of the +form_for+  
266 - tag. Example:  
267 -  
268 - <%=  
269 - form_for(  
270 - :attachment_metadata,  
271 - url: {action: "create"},  
272 - html: {multipart: true}  
273 - ) do |form|  
274 - %>  
275 -  
276 -2. Use the +file_field+ helper with +:uploaded_data+ as the field name. Example:  
277 -  
278 - <%= form.file_field(:uploaded_data) %>  
279 -  
280 -Displaying uploaded images is made easy by the +public_filename+ method of the  
281 -ActiveRecord attachment objects using file system, s3, and Cloud Files storage.  
282 -  
283 -== public_filename(thumbnail = nil)  
284 -  
285 -Returns the public path to the file. If a thumbnail prefix is specified it will  
286 -return the public file path to the corresponding thumbnail. Examples:  
287 -  
288 - attachment_obj.public_filename #=> /attachments/2/file.jpg  
289 - attachment_obj.public_filename(:thumb) #=> /attachments/2/file_thumb.jpg  
290 - attachment_obj.public_filename(:small) #=> /attachments/2/file_small.jpg  
291 -  
292 -When serving files from database storage, doing more than simply downloading the  
293 -file is beyond the scope of this document.  
294 -  
295 -= attachment_fu controllers  
296 -  
297 -There are two considerations to take into account when using attachment_fu in  
298 -controllers.  
299 -  
300 -The first is when the files have no publicly accessible path and need to be  
301 -downloaded through an action. Example:  
302 -  
303 - def readme  
304 - send_file(  
305 - '/path/to/readme.txt',  
306 - type: 'plain/text',  
307 - disposition: 'inline'  
308 - )  
309 - end  
310 -  
311 -See the possible values for +send_file+ for reference.  
312 -  
313 -The second is when saving the file when submitted from a form. Example:  
314 -  
315 -In a view:  
316 -  
317 - <%= form.file_field(:attachable, :uploaded_data) %>  
318 -  
319 -In a controller:  
320 -  
321 - def create  
322 - @attachable_file = AttachmentMetadataModel.new(params[:attachable])  
323 - if @attachable_file.save  
324 - flash[:notice] = 'Attachment was successfully created.'  
325 - redirect_to(attachable_url(@attachable_file))  
326 - else  
327 - redirect_to(action: 'new')  
328 - end  
329 - end  
330 -  
331 -= attachment_fu scripting  
332 -  
333 -You may wish to import a large number of images or attachments. The following  
334 -example shows how to upload a file from a script.  
335 -  
336 - #!/usr/bin/env ./script/runner  
337 -  
338 - # required to use ActionController::TestUploadedFile  
339 - require 'action_controller'  
340 - require 'action_controller/test_process.rb'  
341 -  
342 - path = "./public/images/x.jpg"  
343 -  
344 - # `mimetype` is a string like "image/jpeg". One way to get the mimetype for  
345 - # a given file on a UNIX system: mimetype = `file -ib #{path}`.gsub(/\n/,"")  
346 - mimetype = "image/jpeg"  
347 -  
348 - # This will "upload" the file at path and create the new model.  
349 - @attachable = AttachmentMetadataModel.new(  
350 - uploaded_data: ActionController::TestUploadedFile.new(path, mimetype)  
351 - )  
352 - @attachable.save  
vendor/plugins/pothoven-attachment_fu/Rakefile
@@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
1 -require 'rake'  
2 -require 'rake/testtask'  
3 -require 'rdoc/task'  
4 -  
5 -desc 'Default: run unit tests.'  
6 -task :default => :test  
7 -  
8 -desc 'Test the attachment_fu plugin.'  
9 -Rake::TestTask.new(:test) do |t|  
10 - t.libs << 'lib'  
11 - t.pattern = 'test/**/*_test.rb'  
12 - t.verbose = true  
13 -end  
14 -  
15 -desc 'Generate documentation for the attachment_fu plugin.'  
16 -Rake::RDocTask.new(:rdoc) do |rdoc|  
17 - rdoc.rdoc_dir = 'rdoc'  
18 - rdoc.title = 'ActsAsAttachment'  
19 - rdoc.options << '--line-numbers --inline-source'  
20 - rdoc.rdoc_files.include('README.rdoc')  
21 - rdoc.rdoc_files.include('lib/**/*.rb')  
22 -end  
vendor/plugins/pothoven-attachment_fu/amazon_s3.yml.tpl
@@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
1 -development:  
2 - bucket_name: appname_development  
3 - access_key_id:  
4 - secret_access_key:  
5 - distribution_domain: XXXX.cloudfront.net  
6 -  
7 -test:  
8 - bucket_name: appname_test  
9 - access_key_id:  
10 - secret_access_key:  
11 - distribution_domain: XXXX.cloudfront.net  
12 -  
13 -production:  
14 - bucket_name: appname  
15 - access_key_id:  
16 - secret_access_key:  
17 - distribution_domain: XXXX.cloudfront.net  
vendor/plugins/pothoven-attachment_fu/attachment_fu.gemspec
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -# -*- encoding: utf-8 -*-  
2 -  
3 -Gem::Specification.new do |s|  
4 - s.name = %q{pothoven-attachment_fu}  
5 - s.authors = ["Rick Olson", "Steven Pothoven"]  
6 - s.summary = %q{attachment_fu as a gem}  
7 - s.description = %q{This is a fork of Rick Olson's attachment_fu adding Ruby 1.9 and Rails 3.2 support as well as some other enhancements.}  
8 - s.email = %q{steven@pothoven.net}  
9 - s.homepage = %q{http://github.com/pothoven/attachment_fu}  
10 - s.version = "3.2.10"  
11 - s.date = %q{2013-08-22}  
12 -  
13 - s.files = Dir.glob("{lib,vendor}/**/*") + %w( CHANGELOG LICENSE README.rdoc amazon_s3.yml.tpl rackspace_cloudfiles.yml.tpl )  
14 - s.extra_rdoc_files = ["README.rdoc"]  
15 - s.rdoc_options = ["--inline-source", "--charset=UTF-8"]  
16 - s.require_paths = ["lib"]  
17 - s.rubyforge_project = "nowarning"  
18 - s.rubygems_version = %q{1.3.5}  
19 -  
20 - if s.respond_to? :specification_version then  
21 - s.specification_version = 2  
22 - end  
23 -end  
vendor/plugins/pothoven-attachment_fu/config/database.yml
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -test:  
2 - adapter: sqlite3  
3 - database: ":memory:"  
vendor/plugins/pothoven-attachment_fu/config/environment.rb
vendor/plugins/pothoven-attachment_fu/init.rb
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -require 'geometry'  
2 -ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods)  
3 -Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH)  
4 -FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path  
5 -  
6 -$:.unshift(File.dirname(__FILE__) + '/vendor')  
vendor/plugins/pothoven-attachment_fu/install.rb
@@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
1 -require 'fileutils'  
2 -  
3 -s3_config = File.dirname(__FILE__) + '/../../../config/amazon_s3.yml'  
4 -FileUtils.cp File.dirname(__FILE__) + '/amazon_s3.yml.tpl', s3_config unless File.exist?(s3_config)  
5 -cloudfiles_config = File.dirname(__FILE__) + '/../../../config/rackspace_cloudfiles.yml'  
6 -FileUtils.cp File.dirname(__FILE__) + '/rackspace_cloudfiles.yml.tpl', cloudfiles_config unless File.exist?(cloudfiles_config)  
7 -puts IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))