resque-failed-job-mailer-2 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8ea7b2b4dd11c0a0cad06fa79df3a23a62f102f3
4
+ data.tar.gz: f31891ff881670b4420265e61adcc1189016e43b
5
+ SHA512:
6
+ metadata.gz: ef81563d3126a0bb0d3d24f9fe74d8f8aba8ff207116f2fb33c0ee1b83c8e25c4a54f8b58de1718a9e0e7cef3b47779c3184b1a09627783508a9ff5b672d2850
7
+ data.tar.gz: f3447512eeee58ebe7c191621c76e80b11e7a62cf737555b91af28f8e146075ad756c99bf881bd0ddbbc7b0c733c4ccd8c58026495a71ba5a4dc614636940af3
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea/*
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in resque_failed_job_mailer.gemspec
4
+ gemspec
@@ -0,0 +1,57 @@
1
+ Overview
2
+ --------
3
+
4
+ Send email with predefined template when resque worker die of any reason.
5
+
6
+ Folk from https://github.com/anandagrawal84/resque_failed_job_mailer and customizable.
7
+
8
+ Making it general and seperate from anandagrawal84/resque_failed_job_mailer due to inactive repo.
9
+
10
+
11
+ Installation
12
+ ------------
13
+
14
+ ```bash
15
+ gem install resque-failed-job-mailer-2
16
+ ```
17
+
18
+ Or add to Gemfile:
19
+
20
+ ```
21
+ gem 'resque-failed-job-mailer-2'
22
+ ```
23
+
24
+
25
+ Usage
26
+ -----
27
+ All you need to do is configure ActionMailer for smtp details. Add following configuration file `resque_failed_job_mailer.rb` in `config/initializer` folder
28
+
29
+ ```ruby
30
+ Resque::Failure::Notifier.configure do |config|
31
+ config.from = 'dummy@dummy.com' # from address
32
+ config.to = 'dummy@dummy.com' # to address
33
+ config.include_payload = true # disabled by default for security
34
+ config.include_exception = true # disabled by default for security
35
+ config.tags = ["ProjectX","Wolverine","Resque"] # [ProjectX][Wolverine][Resque] tag displayed in email summary
36
+ end
37
+ ```
38
+
39
+ as soon as resque job fail it would send out an email to the configured email address.
40
+
41
+ Configuration
42
+ -------------
43
+
44
+ If you want to use your own email mechanism then add following configuration
45
+
46
+ ```ruby
47
+ Resque::Failure::Notifier.configure do |config|
48
+ config.mailer = ActionMailerClass
49
+ config.mail = ActionMailerMailMethod
50
+ config.from = 'dummy@dummy.com' # from address
51
+ config.to = 'dummy@dummy.com' # to address
52
+ end
53
+ ```
54
+
55
+ `config.mailer` is any class that extends `ActionMailer::Base`
56
+
57
+ `config.mail` is mail in class given above in `config.mailer`
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,25 @@
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
+ config.tags = ["Resque"]
19
+ config.include_payload = false
20
+ config.include_exception = false
21
+ end
22
+
23
+ module ResqueFailedJobMailer
24
+
25
+ end
@@ -0,0 +1,22 @@
1
+ <p>
2
+ <strong>Queue: </strong>
3
+ <%= @notifier.queue %>
4
+ </p>
5
+ <p>
6
+ <strong>Worker: </strong>
7
+ <%= @notifier.worker %>
8
+ </p>
9
+ <% if @notifier.class.include_payload %>
10
+ <p>
11
+ <strong>Payload: </strong>
12
+ <%= @notifier.payload %>
13
+ </p>
14
+ <% end %>
15
+ <% if @notifier.class.include_exception %>
16
+ <strong> Exception: </strong>
17
+ <p>
18
+ <%= @notifier.exception %>
19
+ <pre><% @notifier.exception.backtrace.each do |t| %><%= t %>
20
+ <% end %></pre>
21
+ </p>
22
+ <% end %>
@@ -0,0 +1,13 @@
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
+ tags = Resque::Failure::Notifier.tags
7
+ subject = "[#{tags.join('][')}] #{@notifier.exception}"
8
+ mail :from => Resque::Failure::Notifier.from, :to => Resque::Failure::Notifier.to, :subject => subject do |format|
9
+ format.html { render :text => text }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,23 @@
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, :include_payload, :include_exception, :tags
8
+
9
+ def configure
10
+ yield self
11
+ self.include_payload = false if include_payload.nil?
12
+ self.include_exception = false if include_exception.nil?
13
+ Resque::Failure.backend = self unless Resque::Failure.backend == Resque::Failure::Multiple
14
+ end
15
+ end
16
+
17
+ def save
18
+ self.class.mailer.send(self.class.mail, self).deliver
19
+ rescue
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module ResqueFailedJobMailer
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,23 @@
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-2"
7
+ s.version = ResqueFailedJobMailer::VERSION
8
+ s.authors = ["Anand Agrawal", "Rajashree Malvade", "An Vo"]
9
+ s.email = ["aagrawal@thoughtworks.com", "rajashreermalvade@gmail.com", "thien.an.vo.nguyen@gmail.com"]
10
+ s.homepage = 'https://github.com/anvox/resque_failed_job_mailer'
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. Extend to customize email summary, payload, exception.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_development_dependency 'rake', '~> 0'
20
+ s.add_development_dependency 'rspec', '~> 0'
21
+ s.add_development_dependency 'actionmailer', '~> 0'
22
+ s.add_development_dependency 'resque', '~> 0'
23
+ end
@@ -0,0 +1,52 @@
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
+
34
+ it "should return default include_payload method" do
35
+ Resque::Failure::Notifier.include_payload.should be_true
36
+ end
37
+ end
38
+
39
+ describe "save" do
40
+ Resque::Failure::Notifier.configure do |config|
41
+ config.mailer = ResqueFailedJobMailer::Mailer
42
+ config.mail = :alert
43
+ end
44
+
45
+ it "should send the mail if job fails" do
46
+ notifier = Resque::Failure::Notifier.new(nil, nil, nil, nil)
47
+ ResqueFailedJobMailer::Mailer.should_receive(:alert).with(notifier).and_return(mail = mock('mail'))
48
+ mail.should_receive(:deliver)
49
+ notifier.save
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-failed-job-mailer-2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Anand Agrawal
8
+ - Rajashree Malvade
9
+ - An Vo
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-01-19 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rspec
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: actionmailer
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: resque
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ description: Gem that sends mail in case of resque job failure. Extend to customize
72
+ email summary, payload, exception.
73
+ email:
74
+ - aagrawal@thoughtworks.com
75
+ - rajashreermalvade@gmail.com
76
+ - thien.an.vo.nguyen@gmail.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - .gitignore
82
+ - .travis.yml
83
+ - Gemfile
84
+ - README.md
85
+ - Rakefile
86
+ - lib/resque_failed_job_mailer.rb
87
+ - lib/resque_failed_job_mailer/alert.html.erb
88
+ - lib/resque_failed_job_mailer/mailer.rb
89
+ - lib/resque_failed_job_mailer/resque/failure/notifier.rb
90
+ - lib/resque_failed_job_mailer/version.rb
91
+ - resque_failed_job_mailer.gemspec
92
+ - spec/resque_failed_job_mailer_spec.rb
93
+ homepage: https://github.com/anvox/resque_failed_job_mailer
94
+ licenses: []
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.8
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Gem that sends mail in case of resque job failure.
116
+ test_files: []
117
+ has_rdoc: