resque-failed-job-mailer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Rakefile +7 -0
- data/lib/resque_failed_job_mailer.rb +22 -0
- data/lib/resque_failed_job_mailer/alert.html.erb +13 -0
- data/lib/resque_failed_job_mailer/mailer.rb +11 -0
- data/lib/resque_failed_job_mailer/resque/failure/notifier.rb +21 -0
- data/lib/resque_failed_job_mailer/version.rb +3 -0
- data/resque_failed_job_mailer.gemspec +25 -0
- data/spec/resque_failed_job_mailer_spec.rb +48 -0
- metadata +109 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "resque_failed_job_mailer/version"
|
2
|
+
require 'resque/server'
|
3
|
+
require 'resque/failure/multiple'
|
4
|
+
require 'resque/failure/redis'
|
5
|
+
require 'action_mailer'
|
6
|
+
require 'resque_failed_job_mailer/mailer'
|
7
|
+
require 'resque_failed_job_mailer/resque/failure/notifier'
|
8
|
+
|
9
|
+
Resque::Failure::Multiple.configure do |config|
|
10
|
+
config.classes = [Resque::Failure::Redis, Resque::Failure::Notifier]
|
11
|
+
end
|
12
|
+
|
13
|
+
Resque::Failure::Notifier.configure do |config|
|
14
|
+
config.mailer = ResqueFailedJobMailer::Mailer
|
15
|
+
config.mail = :alert
|
16
|
+
config.from = "no_reply@gmail.com"
|
17
|
+
config.to = "dummy@dummy.com"
|
18
|
+
end
|
19
|
+
|
20
|
+
module ResqueFailedJobMailer
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ResqueFailedJobMailer
|
2
|
+
class Mailer < ::ActionMailer::Base
|
3
|
+
def alert notifier
|
4
|
+
@notifier = notifier
|
5
|
+
text = ERB.new(File.read(File.dirname(__FILE__) + "/alert.html.erb")).result(binding)
|
6
|
+
mail :from => Resque::Failure::Notifier.from, :to => Resque::Failure::Notifier.to, :subject => "[Resque] #{@notifier.exception}" do |format|
|
7
|
+
format.html { render :text => text }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'action_mailer'
|
2
|
+
|
3
|
+
module Resque
|
4
|
+
module Failure
|
5
|
+
class Notifier < Base
|
6
|
+
class << self
|
7
|
+
attr_accessor :mailer, :mail, :from, :to
|
8
|
+
|
9
|
+
def configure
|
10
|
+
yield self
|
11
|
+
Resque::Failure.backend = self unless Resque::Failure.backend == Resque::Failure::Multiple
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def save
|
16
|
+
self.class.mailer.send(self.class.mail, self).deliver
|
17
|
+
rescue
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "resque_failed_job_mailer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "resque-failed-job-mailer"
|
7
|
+
s.version = ResqueFailedJobMailer::VERSION
|
8
|
+
s.authors = ["Anand Agrawal", "Rajashree Malvade"]
|
9
|
+
s.email = ["aagrawal@thoughtworks.com", "rajashreermalvade@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Gem that sends mail in case of resque job failure}
|
12
|
+
s.description = %q{Gem that sends mail in case of resque job failure}
|
13
|
+
|
14
|
+
s.rubyforge_project = "resque-failed-job-mailer"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency "rake"
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
s.add_development_dependency "actionmailer"
|
24
|
+
s.add_development_dependency "resque"
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'resque/server'
|
2
|
+
require 'resque/failure/multiple'
|
3
|
+
require 'resque/failure/redis'
|
4
|
+
require 'action_mailer'
|
5
|
+
require 'resque_failed_job_mailer/mailer'
|
6
|
+
require 'resque_failed_job_mailer/resque/failure/notifier'
|
7
|
+
|
8
|
+
describe Resque::Failure::Notifier do
|
9
|
+
|
10
|
+
describe "configure" do
|
11
|
+
Resque::Failure::Notifier.configure do |config|
|
12
|
+
config.mailer = ResqueFailedJobMailer::Mailer
|
13
|
+
config.mail = :alert
|
14
|
+
config.from = "no_reply@gmail.com"
|
15
|
+
config.to = "dummy@dummy.com"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return mailer class" do
|
19
|
+
Resque::Failure::Notifier.mailer.should == ResqueFailedJobMailer::Mailer
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return mail method" do
|
23
|
+
Resque::Failure::Notifier.mail.should == :alert
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return sender address" do
|
27
|
+
Resque::Failure::Notifier.from.should == "no_reply@gmail.com"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return recipient address" do
|
31
|
+
Resque::Failure::Notifier.to.should == "dummy@dummy.com"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "save" do
|
36
|
+
Resque::Failure::Notifier.configure do |config|
|
37
|
+
config.mailer = ResqueFailedJobMailer::Mailer
|
38
|
+
config.mail = :alert
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should send the mail if job fails" do
|
42
|
+
notifier = Resque::Failure::Notifier.new(nil, nil, nil, nil)
|
43
|
+
ResqueFailedJobMailer::Mailer.should_receive(:alert).with(notifier).and_return(mail = mock('mail'))
|
44
|
+
mail.should_receive(:deliver)
|
45
|
+
notifier.save
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque-failed-job-mailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anand Agrawal
|
9
|
+
- Rajashree Malvade
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-07-25 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: &70324705718000 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70324705718000
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &70324705717380 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70324705717380
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: actionmailer
|
39
|
+
requirement: &70324705716580 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *70324705716580
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: resque
|
50
|
+
requirement: &70324705716140 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *70324705716140
|
59
|
+
description: Gem that sends mail in case of resque job failure
|
60
|
+
email:
|
61
|
+
- aagrawal@thoughtworks.com
|
62
|
+
- rajashreermalvade@gmail.com
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- .travis.yml
|
69
|
+
- Gemfile
|
70
|
+
- Rakefile
|
71
|
+
- lib/resque_failed_job_mailer.rb
|
72
|
+
- lib/resque_failed_job_mailer/alert.html.erb
|
73
|
+
- lib/resque_failed_job_mailer/mailer.rb
|
74
|
+
- lib/resque_failed_job_mailer/resque/failure/notifier.rb
|
75
|
+
- lib/resque_failed_job_mailer/version.rb
|
76
|
+
- resque_failed_job_mailer.gemspec
|
77
|
+
- spec/resque_failed_job_mailer_spec.rb
|
78
|
+
homepage: ''
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
hash: 994557905120790897
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: 994557905120790897
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project: resque-failed-job-mailer
|
104
|
+
rubygems_version: 1.8.12
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Gem that sends mail in case of resque job failure
|
108
|
+
test_files:
|
109
|
+
- spec/resque_failed_job_mailer_spec.rb
|