dj_remixes 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,3 +1,113 @@
1
- README
2
- ========================================================================
3
- dj_remixes was developed by: markbates
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', :git => 'git://github.com/collectiveidea/delayed_job.git'
23
+ gem 'dj_remixes', '>= 0.2.0'
24
+
25
+ Then install the gems:
26
+
27
+ $ bundle install
28
+
29
+ *NOTE*: At this time DJ Remixes requires the latest and greatest in the delayed_job master branch. When DJ 2.1.0 is officially released this requirement should go away.
30
+
31
+ ==Using
32
+
33
+ ===Basic Worker
34
+
35
+ class FooWorker < DJ::Worker
36
+
37
+ def perform
38
+ # do work
39
+ end
40
+
41
+ end
42
+
43
+ FooWorker.enqueue
44
+
45
+ ===Unique Worker
46
+
47
+ Tell DJ to only allow one of this worker at a given time.
48
+
49
+ # We only want to charge the card once!
50
+ class PurchaseWorker < DJ::Worker
51
+ is_unique
52
+
53
+ def perform
54
+ # charge the credit card...
55
+ end
56
+ end
57
+
58
+ 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.
59
+
60
+ ===Priority
61
+
62
+ Tell DJ to run this worker with a higher priority than others.
63
+
64
+ class FooWorker < DJ::Worker
65
+ priority :high
66
+
67
+ def perform
68
+ # do work
69
+ end
70
+
71
+ end
72
+
73
+ FooWorker.enqueue
74
+
75
+ ===Re-Enqueueing
76
+
77
+ 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.
78
+
79
+ # Run every 30 days and charge a credit card.
80
+ class SubscriptionWorker < DJ::Worker
81
+ re_enqueue
82
+
83
+ def run_at
84
+ 30.days.from_now
85
+ end
86
+
87
+ def perform
88
+ # charge the credit card...
89
+ end
90
+ end
91
+
92
+ ===Attributes
93
+
94
+ The <code>DJ::Worker</code> class can accept attributes, similar to the way an <code>ActiveRecord</code> model can.
95
+
96
+ class FooWorker < DJ::Worker
97
+ priority :high
98
+
99
+ def perform
100
+ # do work
101
+ puts self.id # => 1
102
+ puts self.person # => 'Mark Bates'
103
+ end
104
+
105
+ end
106
+
107
+ worker = FooWorker.new(:id => 1, :person => 'Mark Bates')
108
+ worker.enqueue!
109
+
110
+ ==Contributors
111
+
112
+ * Mark Bates
113
+ * Lars Pind
@@ -17,6 +17,7 @@ module Mail
17
17
  if ActionMailer::Base.delivery_method == :test
18
18
  deliver_without_worker
19
19
  else
20
+ puts self
20
21
  Mail::Message::MailmanWorker.enqueue(:mail => Marshal.dump(self), :klass => self.delivery_handler.name)
21
22
  return self
22
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - markbates
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-15 00:00:00 -04:00
17
+ date: 2010-11-04 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- hash: 3113747627345364661
76
+ hash: 1738724149579697514
77
77
  segments:
78
78
  - 0
79
79
  version: "0"