que-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +178 -0
- data/Rakefile +2 -0
- data/lib/generators/que/install_generator.rb +22 -0
- data/lib/generators/que/templates/add_que.rb +11 -0
- data/lib/que-rails.rb +1 -0
- data/lib/que/rails.rb +9 -0
- data/lib/que/rails/railtie.rb +30 -0
- data/lib/que/rails/rake_tasks.rb +46 -0
- data/lib/que/rails/version.rb +5 -0
- data/que-rails.gemspec +28 -0
- data/spec/configuration_spec.rb +19 -0
- data/spec/rake_tasks_spec.rb +23 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/support/helpers.rb +11 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0a34fa7c415b733e7f209815c1e0c7e86fe97b05
|
4
|
+
data.tar.gz: c1f2c10098b3a8357e239b441fd3f340115e6322
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55be461274eee4ec9a36d8076df7571ac040b5eaa670a2e7ff7501282d2f89baef51c87f8b3e784a1fd219145ac25f8f81bd764dd84f3a119f7666ad80022466
|
7
|
+
data.tar.gz: dff6ae37ab8bc01943a5a043465ed6bd8959302eca679433c953f6c41ea4468b943622b26f2d3a75e3dcd0840504e3bb8317e14490688b8af0ee43095c612d52
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Chris Hanks
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
# que-rails (Unreleased, do not use)
|
2
|
+
|
3
|
+
`que-rails` contains assorted tools that integrate the [Que job queue](https://github.com/chanks/que) into a Rails application. It provides rake tasks and a railtie that handles spinning up the background worker pool.
|
4
|
+
|
5
|
+
This document covers basic information on setting up and using Que in a standard Rails application, and assumes you're using Rails 4. *`que-rails` isn't tested with versions of Rails before 4, and may or may not work with them.* For information on more advanced usage of Que, see its [documentation](https://github.com/chanks/que/tree/master/docs).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'que-rails'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install que-rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
First, generate and run a migration for the `que_jobs` table.
|
24
|
+
|
25
|
+
$ bin/rails generate que:install
|
26
|
+
$ bin/rake db:migrate
|
27
|
+
|
28
|
+
Create a class for each type of job you want to run:
|
29
|
+
|
30
|
+
``` ruby
|
31
|
+
# app/jobs/charge_credit_card.rb
|
32
|
+
class ChargeCreditCard < Que::Job
|
33
|
+
# Default settings for this job. These are optional - without them, jobs
|
34
|
+
# will default to priority 100 and run immediately.
|
35
|
+
@priority = 10
|
36
|
+
@run_at = proc { 1.minute.from_now }
|
37
|
+
|
38
|
+
def run(user_id, options)
|
39
|
+
# Do stuff.
|
40
|
+
user = User.find(user_id)
|
41
|
+
card = CreditCard.find(options[:credit_card_id])
|
42
|
+
|
43
|
+
ActiveRecord::Base.transaction do
|
44
|
+
# Write any changes you'd like to the database.
|
45
|
+
user.update :charged_at => Time.now
|
46
|
+
card.update :charged_at => Time.now
|
47
|
+
|
48
|
+
# It's best to destroy the job in the same transaction as any other
|
49
|
+
# changes you make. Que will destroy the job for you after the run
|
50
|
+
# method if you don't do it yourself, but if your job writes to the
|
51
|
+
# DB but doesn't destroy the job in the same transaction, it's
|
52
|
+
# possible that the job could be repeated in the event of a crash.
|
53
|
+
destroy
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
See the docs on [how to write a reliable job](https://github.com/chanks/que/blob/master/docs/writing_reliable_jobs.md) for more information on writing different types of jobs safely.
|
60
|
+
|
61
|
+
Queue your job. Again, it's best to do this in a transaction with other changes you're making. Also note that any arguments you pass will be serialized to JSON and back again, so stick to simple types (strings, integers, floats, hashes, and arrays).
|
62
|
+
|
63
|
+
``` ruby
|
64
|
+
ActiveRecord::Base.transaction do
|
65
|
+
# Persist credit card information
|
66
|
+
card = CreditCard.create(params[:credit_card])
|
67
|
+
ChargeCreditCard.enqueue(current_user.id, :credit_card_id => card.id)
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
You can also add options to run the job after a specific time, or with a specific priority:
|
72
|
+
|
73
|
+
``` ruby
|
74
|
+
# The default priority is 100, and a lower number means a higher priority. 5 would be very important.
|
75
|
+
ChargeCreditCard.enqueue current_user.id, :credit_card_id => card.id, :run_at => 1.day.from_now, :priority => 5
|
76
|
+
```
|
77
|
+
|
78
|
+
To determine what happens when a job is queued, you can set Que's mode in your application configuration. There are a few options for the mode:
|
79
|
+
|
80
|
+
* `config.que.mode = :off` - In this mode, queueing a job will simply insert it into the database - the current process will make no effort to run it. You should use this if you want to use a dedicated process to work tasks (there's a rake task to do this, see below). This is the default when running `bin/rails console`.
|
81
|
+
* `config.que.mode = :async` - In this mode, a pool of background workers is spun up, each running in their own thread. This is the default when running `bin/rails server`. See the docs for [more information on managing workers](https://github.com/chanks/que/blob/master/docs/managing_workers.md).
|
82
|
+
* `config.que.mode = :sync` - In this mode, any jobs you queue will be run in the same thread, synchronously (that is, `MyJob.enqueue` runs the job and won't return until it's completed). This makes your application's behavior easier to test, so it's the default in the test environment.
|
83
|
+
|
84
|
+
If you're using ActiveRecord to dump your database's schema, you'll probably want to [set schema_format to :sql](http://guides.rubyonrails.org/migrations.html#types-of-schema-dumps) so that Que's table structure is managed correctly.
|
85
|
+
|
86
|
+
### Forking Servers
|
87
|
+
|
88
|
+
If you want to run a worker pool in your web process and you're using a forking webserver like Phusion Passenger (in smart spawning mode), Unicorn or Puma (in some configurations), you'll want to set `Que.mode = :off` in your application configuration and only start up the worker pool in the child processes after the DB connection has been reestablished.
|
89
|
+
|
90
|
+
#### Puma
|
91
|
+
|
92
|
+
# config/puma.rb
|
93
|
+
on_worker_boot do
|
94
|
+
ActiveRecord::Base.establish_connection
|
95
|
+
|
96
|
+
Que.mode = :async
|
97
|
+
end
|
98
|
+
|
99
|
+
#### Unicorn
|
100
|
+
|
101
|
+
# config/unicorn.rb
|
102
|
+
after_fork do |server, worker|
|
103
|
+
ActiveRecord::Base.establish_connection
|
104
|
+
|
105
|
+
Que.mode = :async
|
106
|
+
end
|
107
|
+
|
108
|
+
#### Phusion Passenger
|
109
|
+
|
110
|
+
# config.ru
|
111
|
+
if defined?(PhusionPassenger)
|
112
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
113
|
+
if forked
|
114
|
+
Que.mode = :async
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
### Other ORMs
|
120
|
+
|
121
|
+
If you're using an ORM other than ActiveRecord, you'll need to pass Que the connection manually. For instance, if you're using Sequel, you could do this after you initialize the database connection:
|
122
|
+
|
123
|
+
# config/initializers/sequel.rb
|
124
|
+
DB = Sequel.connect(ENV['DATABASE_URL'])
|
125
|
+
Que.connection = DB
|
126
|
+
|
127
|
+
### Rake Tasks
|
128
|
+
|
129
|
+
If you don't want to burden your web processes with too much work and want to run workers in a background process instead, similar to how most other queues work, `que-rails` provides a rake task:
|
130
|
+
|
131
|
+
# Run a pool of 4 workers:
|
132
|
+
rake que:work
|
133
|
+
|
134
|
+
# Or configure the number of workers:
|
135
|
+
QUE_WORKER_COUNT=8 rake que:work
|
136
|
+
|
137
|
+
Other options available via environment variables are `QUE_QUEUE` to determine which named queue jobs are pulled from, and `QUE_WAKE_INTERVAL` to determine how long workers will wait to poll again when there are no jobs available. For example, to run 2 workers that run jobs from the "other_queue" queue and wait a half-second between polls, you could do:
|
138
|
+
|
139
|
+
QUE_QUEUE=other_queue QUE_WORKER_COUNT=2 QUE_WAKE_INTERVAL=0.5 rake que:work
|
140
|
+
|
141
|
+
### Additional Configuration
|
142
|
+
|
143
|
+
You can use the config.que object in your application config files to do whatever other setup you'd like. For example, you'll probably want to define an error handler, in order to pass errors raised by jobs to whatever tracking system you use:
|
144
|
+
|
145
|
+
config.que.error_handler = proc { |error| ... }
|
146
|
+
|
147
|
+
You can also manually set the number of workers in each process:
|
148
|
+
|
149
|
+
config.que.worker_count = 8
|
150
|
+
|
151
|
+
### Thread Safety
|
152
|
+
|
153
|
+
If your application code is not thread-safe, you won't want any workers to be processing jobs while anything else is happening in the Ruby process. So, you'll want to turn the worker pool off by default:
|
154
|
+
|
155
|
+
config.que.mode = :off
|
156
|
+
|
157
|
+
This will prevent Que from trying to process jobs in the background of your web processes. In order to actually work jobs, you'll want to run a single worker at a time, and to do so via a separate rake task, like so:
|
158
|
+
|
159
|
+
QUE_WORKER_COUNT=1 rake que:work
|
160
|
+
|
161
|
+
## Gem TODO
|
162
|
+
|
163
|
+
- Spec multiple versions of Rails, not just one.
|
164
|
+
- Spec the `rake que:work` task and its various options.
|
165
|
+
- Spec the generator more thoroughly.
|
166
|
+
- Spec that things don't fail when ActiveRecord isn't being used.
|
167
|
+
- Spec that Que can be configured successfully in an initializer or in the application or environment config files. This includes things like wake_interval, worker_count, etc.
|
168
|
+
- Spec that the worker pool starts up when Rails is running as a server, but not when running as a console or when running other rake tasks (like `db:migrate` or `routes`).
|
169
|
+
- Spec that the code samples for using Que with forking webservers all work (Unicorn, Phusion Passenger, Puma).
|
170
|
+
- Add handlers for common error services (Honeybadger, etc).
|
171
|
+
|
172
|
+
## Contributing
|
173
|
+
|
174
|
+
1. Fork it ( https://github.com/[my-github-username]/que-rails/fork )
|
175
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
176
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
177
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
178
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
module Que
|
6
|
+
class InstallGenerator < ::Rails::Generators::Base
|
7
|
+
include ::Rails::Generators::Migration
|
8
|
+
|
9
|
+
namespace 'que:install'
|
10
|
+
self.source_paths << File.join(File.dirname(__FILE__), 'templates')
|
11
|
+
desc "Generates a migration to add Que's job table."
|
12
|
+
|
13
|
+
def self.next_migration_number(dirname)
|
14
|
+
next_migration_number = current_migration_number(dirname) + 1
|
15
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_migration_file
|
19
|
+
migration_template 'add_que.rb', 'db/migrate/add_que.rb'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/que-rails.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'que/rails'
|
data/lib/que/rails.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Que
|
2
|
+
module Rails
|
3
|
+
class Railtie < ::Rails::Railtie
|
4
|
+
config.que = Que
|
5
|
+
|
6
|
+
Que.logger = proc { ::Rails.logger }
|
7
|
+
Que.mode = :sync if ::Rails.env.test?
|
8
|
+
Que.connection = ::ActiveRecord if defined? ::ActiveRecord
|
9
|
+
|
10
|
+
rake_tasks do
|
11
|
+
load 'que/rails/rake_tasks.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
initializer 'que.setup' do
|
15
|
+
::ActiveSupport.on_load :after_initialize do
|
16
|
+
# Only start up the worker pool if running as a server.
|
17
|
+
Que.mode ||= defined?(::Rails::Server) ? :async : :off
|
18
|
+
|
19
|
+
at_exit do
|
20
|
+
if Que.mode == :async
|
21
|
+
$stdout.puts "Finishing Que's current jobs before exiting..."
|
22
|
+
Que.mode = :off
|
23
|
+
$stdout.puts "Que's jobs finished, exiting..."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
namespace :que do
|
2
|
+
desc "Process Que's jobs using a worker pool"
|
3
|
+
task :work => :environment do
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
Que.logger = Logger.new(STDOUT)
|
7
|
+
Que.logger.level = Logger.const_get((ENV['QUE_LOG_LEVEL'] || 'INFO').upcase)
|
8
|
+
Que.worker_count = (ENV['QUE_WORKER_COUNT'] || 4).to_i
|
9
|
+
Que.wake_interval = (ENV['QUE_WAKE_INTERVAL'] || 0.1).to_f
|
10
|
+
Que.mode = :async
|
11
|
+
|
12
|
+
# When changing how signals are caught, be sure to test the behavior with
|
13
|
+
# the rake task in tasks/safe_shutdown.rb.
|
14
|
+
|
15
|
+
stop = false
|
16
|
+
%w( INT TERM ).each do |signal|
|
17
|
+
trap(signal) {stop = true}
|
18
|
+
end
|
19
|
+
|
20
|
+
at_exit do
|
21
|
+
$stdout.puts "Finishing Que's current jobs before exiting..."
|
22
|
+
Que.mode = :off
|
23
|
+
$stdout.puts "Que's jobs finished, exiting..."
|
24
|
+
end
|
25
|
+
|
26
|
+
loop do
|
27
|
+
sleep 0.01
|
28
|
+
break if stop
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Migrate Que's job table to the most recent version (creating it if it doesn't exist)"
|
33
|
+
task :migrate => :environment do
|
34
|
+
Que.migrate! :version => (ENV['QUE_MIGRATE_VERSION'] || Que::Migrations::CURRENT_VERSION).to_i
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Drop Que's job table"
|
38
|
+
task :drop => :environment do
|
39
|
+
Que.drop!
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Clear Que's job table"
|
43
|
+
task :clear => :environment do
|
44
|
+
Que.clear!
|
45
|
+
end
|
46
|
+
end
|
data/que-rails.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'que/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'que-rails'
|
8
|
+
spec.version = Que::Rails::VERSION
|
9
|
+
spec.authors = ["Chris Hanks"]
|
10
|
+
spec.email = ["christopher.m.hanks@gmail.com"]
|
11
|
+
spec.summary = %q{Que for Rails}
|
12
|
+
spec.description = %q{Railtie, Generators and other magic to integrate the Que job queue with Rails applications.}
|
13
|
+
spec.homepage = 'https://github.com/chanks/que-rails'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'que', '~> 0.9'
|
22
|
+
spec.add_dependency 'railties', '~> 4.1.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'sequel'
|
27
|
+
spec.add_development_dependency 'pg'
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Que::Rails::Railtie" do
|
4
|
+
it "should set Que's logger to the Rails logger" do
|
5
|
+
rails_runner('puts Que.logger == Rails.logger').should == 'true'
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should use ActiveRecord's DB connection" do
|
9
|
+
rails_runner('puts Que.execute("SELECT 1 AS one")').should == '{"one"=>1}'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should leave Que off by default when run as rails runner" do
|
13
|
+
rails_runner('puts Que.mode.inspect').should == ':off'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should start Que in :sync mode when in test mode" do
|
17
|
+
rails_runner('puts Que.mode.inspect', :variables => 'RAILS_ENV=test').should == ':sync'
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "que-rails rake tasks" do
|
4
|
+
it "should include a task for migrating Que's job table" do
|
5
|
+
in_path($app_copy_path) do
|
6
|
+
DB.table_exists?(:que_jobs).should be true
|
7
|
+
`QUE_MIGRATE_VERSION=0 rake que:migrate`
|
8
|
+
DB.table_exists?(:que_jobs).should be false
|
9
|
+
`rake que:migrate`
|
10
|
+
DB.table_exists?(:que_jobs).should be true
|
11
|
+
|
12
|
+
DB[:que_jobs].insert(job_class: 'Que::Job')
|
13
|
+
DB[:que_jobs].count.should == 1
|
14
|
+
`rake que:clear`
|
15
|
+
DB[:que_jobs].count.should == 0
|
16
|
+
|
17
|
+
`rake que:drop`
|
18
|
+
DB.table_exists?(:que_jobs).should be false
|
19
|
+
`rake que:migrate`
|
20
|
+
DB.table_exists?(:que_jobs).should be true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
|
3
|
+
DB = Sequel.connect ENV['DATABASE_URL'] || "postgres:///que_rails_test_app_development"
|
4
|
+
|
5
|
+
require 'support/helpers'
|
6
|
+
|
7
|
+
puts "Testing Que's integration with #{`rails -v`}"
|
8
|
+
|
9
|
+
$test_app_path = "spec/tmp/que_rails_test_app"
|
10
|
+
$app_copy_path = "spec/tmp/app_copy"
|
11
|
+
|
12
|
+
FileUtils.rm_rf($test_app_path)
|
13
|
+
FileUtils.rm_rf($app_copy_path)
|
14
|
+
|
15
|
+
# Drop spec directory.
|
16
|
+
directory = File.dirname(__FILE__).split('/')[0..-2].join('/')
|
17
|
+
|
18
|
+
# Skip bundle install until we add que-rails.
|
19
|
+
`rails new #{$test_app_path} -B -d postgresql`
|
20
|
+
|
21
|
+
append_to_file "#{$test_app_path}/Gemfile", "gem 'que-rails', :path => '#{directory}'"
|
22
|
+
|
23
|
+
in_path $test_app_path do
|
24
|
+
`bundle`
|
25
|
+
`rails generate que:install`
|
26
|
+
`rake db:drop`
|
27
|
+
`rake db:create`
|
28
|
+
`rake db:migrate`
|
29
|
+
end
|
30
|
+
|
31
|
+
FileUtils.cp_r($test_app_path, $app_copy_path)
|
32
|
+
|
33
|
+
# def add_to_config(str)
|
34
|
+
# environment = File.read("#{$app_copy_path}/config/application.rb")
|
35
|
+
# if environment =~ /(\n\s*end\s*end\s*)\Z/
|
36
|
+
# File.open("#{$app_copy_path}/config/application.rb", 'w') do |f|
|
37
|
+
# f.puts $` + "\n#{str}\n" + $1
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
# end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def append_to_file(file, text)
|
2
|
+
File.open(file, 'a') { |f| f.puts text }
|
3
|
+
end
|
4
|
+
|
5
|
+
def in_path(path, &block)
|
6
|
+
Bundler.with_clean_env { Dir.chdir(path, &block) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def rails_runner(ruby, options = {})
|
10
|
+
in_path($app_copy_path) { `#{options[:variables]} rails r '#{ruby}'`.strip }
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: que-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Hanks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: que
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sequel
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pg
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Railtie, Generators and other magic to integrate the Que job queue with
|
98
|
+
Rails applications.
|
99
|
+
email:
|
100
|
+
- christopher.m.hanks@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .rspec
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/generators/que/install_generator.rb
|
112
|
+
- lib/generators/que/templates/add_que.rb
|
113
|
+
- lib/que-rails.rb
|
114
|
+
- lib/que/rails.rb
|
115
|
+
- lib/que/rails/railtie.rb
|
116
|
+
- lib/que/rails/rake_tasks.rb
|
117
|
+
- lib/que/rails/version.rb
|
118
|
+
- que-rails.gemspec
|
119
|
+
- spec/configuration_spec.rb
|
120
|
+
- spec/rake_tasks_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
- spec/support/helpers.rb
|
123
|
+
homepage: https://github.com/chanks/que-rails
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.2.2
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Que for Rails
|
147
|
+
test_files:
|
148
|
+
- spec/configuration_spec.rb
|
149
|
+
- spec/rake_tasks_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
- spec/support/helpers.rb
|