dj_remixes 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dj_remixes/airbrake.rb +15 -0
- data/lib/dj_remixes/requires.rb +1 -0
- metadata +15 -8
- data/README +0 -131
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
if Object.const_defined?(:Airbrake)
|
|
2
|
+
module DJ
|
|
3
|
+
class Worker
|
|
4
|
+
|
|
5
|
+
# Report Errors to Airbrake:
|
|
6
|
+
def error_with_airbrake(job, error)
|
|
7
|
+
Airbrake.notify_or_ignore(error, :cgi_data => self.dj_object.attributes)
|
|
8
|
+
error_without_airbrake(job, error)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
alias_method_chain :error, :airbrake
|
|
12
|
+
|
|
13
|
+
end # Worker
|
|
14
|
+
end # DJ
|
|
15
|
+
end # defined?
|
data/lib/dj_remixes/requires.rb
CHANGED
metadata
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: dj_remixes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease:
|
|
5
|
-
version: 0.
|
|
5
|
+
version: 0.3.0
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- markbates
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-
|
|
13
|
+
date: 2011-08-26 00:00:00 -04:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|
|
@@ -24,6 +24,17 @@ dependencies:
|
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: *id001
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: delayed_job
|
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
30
|
+
none: false
|
|
31
|
+
requirements:
|
|
32
|
+
- - <
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: 3.0.0
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: *id002
|
|
27
38
|
description: "dj_remixes was developed by: markbates"
|
|
28
39
|
email: mark@markbates.com
|
|
29
40
|
executables: []
|
|
@@ -31,12 +42,12 @@ executables: []
|
|
|
31
42
|
extensions: []
|
|
32
43
|
|
|
33
44
|
extra_rdoc_files:
|
|
34
|
-
- README
|
|
35
45
|
- LICENSE
|
|
36
46
|
files:
|
|
37
47
|
- lib/dj_remixes/action_mailer/action_mailer.rb
|
|
38
48
|
- lib/dj_remixes/action_mailer/action_mailer_railtie.rb
|
|
39
49
|
- lib/dj_remixes/active_record_railtie.rb
|
|
50
|
+
- lib/dj_remixes/airbrake.rb
|
|
40
51
|
- lib/dj_remixes/attributes.rb
|
|
41
52
|
- lib/dj_remixes/callbacks.rb
|
|
42
53
|
- lib/dj_remixes/dj_remixes.rb
|
|
@@ -49,7 +60,6 @@ files:
|
|
|
49
60
|
- lib/dj_remixes/unique_validator.rb
|
|
50
61
|
- lib/dj_remixes/worker.rb
|
|
51
62
|
- lib/dj_remixes.rb
|
|
52
|
-
- README
|
|
53
63
|
- LICENSE
|
|
54
64
|
has_rdoc: true
|
|
55
65
|
homepage: http://www.metabates.com
|
|
@@ -65,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
65
75
|
requirements:
|
|
66
76
|
- - ">="
|
|
67
77
|
- !ruby/object:Gem::Version
|
|
68
|
-
hash: -
|
|
78
|
+
hash: -989871746247076953
|
|
69
79
|
segments:
|
|
70
80
|
- 0
|
|
71
81
|
version: "0"
|
|
@@ -74,9 +84,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
84
|
requirements:
|
|
75
85
|
- - ">="
|
|
76
86
|
- !ruby/object:Gem::Version
|
|
77
|
-
hash: -992275969709892340
|
|
78
|
-
segments:
|
|
79
|
-
- 0
|
|
80
87
|
version: "0"
|
|
81
88
|
requirements: []
|
|
82
89
|
|
data/README
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
=DJ Remixes
|
|
2
|
-
|
|
3
|
-
A boat load of incredibly useful 'plugins' for Delayed::Job! DJ is a wonderful project and is incredibly useful, however it can be even more useful with just a few extras added in.
|
|
4
|
-
|
|
5
|
-
==The Extras
|
|
6
|
-
|
|
7
|
-
* A proper 'Worker' class: DJ::Worker that accepts attributes.
|
|
8
|
-
* Callbacks
|
|
9
|
-
* Hoptoad support, if using Hoptoad.
|
|
10
|
-
* Priority settings
|
|
11
|
-
* Automatic re-enqueueing
|
|
12
|
-
* Better scheduling
|
|
13
|
-
* Unique jobs.
|
|
14
|
-
* more ...
|
|
15
|
-
|
|
16
|
-
These are a few of the extras for DJ that are included here.
|
|
17
|
-
|
|
18
|
-
==Installation
|
|
19
|
-
|
|
20
|
-
In your <code>Gemfile</code> add the following:
|
|
21
|
-
|
|
22
|
-
gem "delayed_job", "2.1.4"
|
|
23
|
-
gem "dj_remixes"
|
|
24
|
-
|
|
25
|
-
Then install the gems:
|
|
26
|
-
|
|
27
|
-
$ bundle install
|
|
28
|
-
|
|
29
|
-
Create a migration to add the required dj_remixes fields to the delayed_job table:
|
|
30
|
-
|
|
31
|
-
class AddDjRemixesColumns < ActiveRecord::Migration
|
|
32
|
-
def self.up
|
|
33
|
-
add_column :delayed_jobs, :worker_class_name, :string
|
|
34
|
-
add_column :delayed_jobs, :started_at, :datetime
|
|
35
|
-
add_column :delayed_jobs, :finished_at, :datetime
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def self.down
|
|
39
|
-
remove_column :delayed_jobs, :worker_class_name
|
|
40
|
-
remove_column :delayed_jobs, :started_at
|
|
41
|
-
remove_column :delayed_jobs, :finished_at
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
==Using
|
|
47
|
-
|
|
48
|
-
===Basic Worker
|
|
49
|
-
|
|
50
|
-
class FooWorker < DJ::Worker
|
|
51
|
-
|
|
52
|
-
def perform
|
|
53
|
-
# do work
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
FooWorker.enqueue
|
|
59
|
-
|
|
60
|
-
===Unique Worker
|
|
61
|
-
|
|
62
|
-
Tell DJ to only allow one of this worker at a given time.
|
|
63
|
-
|
|
64
|
-
# We only want to charge the card once!
|
|
65
|
-
class PurchaseWorker < DJ::Worker
|
|
66
|
-
is_unique
|
|
67
|
-
|
|
68
|
-
def perform
|
|
69
|
-
# charge the credit card...
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
If the worker has an <code>id</code> attribute that then will be used in conjunction with the class name of the worker to form the unique key.
|
|
74
|
-
|
|
75
|
-
===Priority
|
|
76
|
-
|
|
77
|
-
Tell DJ to run this worker with a higher priority than others.
|
|
78
|
-
|
|
79
|
-
class FooWorker < DJ::Worker
|
|
80
|
-
priority :high
|
|
81
|
-
|
|
82
|
-
def perform
|
|
83
|
-
# do work
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
FooWorker.enqueue
|
|
89
|
-
|
|
90
|
-
===Re-Enqueueing
|
|
91
|
-
|
|
92
|
-
Tell DJ to re-enqueue this worker after it has successfully completely. *NOTE*: This will actually create a new DJ object in the database, not reuse the same one.
|
|
93
|
-
|
|
94
|
-
# Run every 30 days and charge a credit card.
|
|
95
|
-
class SubscriptionWorker < DJ::Worker
|
|
96
|
-
re_enqueue
|
|
97
|
-
|
|
98
|
-
def run_at
|
|
99
|
-
30.days.from_now
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def perform
|
|
103
|
-
# charge the credit card...
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
===Attributes
|
|
108
|
-
|
|
109
|
-
The <code>DJ::Worker</code> class can accept attributes, similar to the way an <code>ActiveRecord</code> model can.
|
|
110
|
-
|
|
111
|
-
class FooWorker < DJ::Worker
|
|
112
|
-
priority :high
|
|
113
|
-
|
|
114
|
-
def perform
|
|
115
|
-
# do work
|
|
116
|
-
puts self.id # => 1
|
|
117
|
-
puts self.person # => 'Mark Bates'
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
worker = FooWorker.new(:id => 1, :person => 'Mark Bates')
|
|
123
|
-
worker.enqueue!
|
|
124
|
-
|
|
125
|
-
==Contributors
|
|
126
|
-
|
|
127
|
-
* Mark Bates
|
|
128
|
-
* Stuart Garner
|
|
129
|
-
* Brent Kirby
|
|
130
|
-
* Luke Pearce
|
|
131
|
-
* Lars Pindrake
|