resque_action_mailer_backend 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ nbproject/*
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Maurício Linhares
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,43 @@
1
+ = resque_action_mailer_backend
2
+
3
+ With this gem you will be able to enqueue your emails
4
+ on your Resque workers to avoid making your user wait for the email to be
5
+ send when he causes an email sending action in your application.
6
+
7
+ Using resque_action_mailer_backend makes email sending a breeze as
8
+ you will be able to use Resque to retry failed emails, easily deliver all
9
+ those marketing emails to your clients and without changing anything at
10
+ your email sending code.
11
+
12
+ Just tell your application to use :resque for sending emails and you're done,
13
+ no need to add yet another tool just for delivering your emails if you're
14
+ already using Resque for your asynchronous processing.
15
+
16
+ And a special thanks for the ar_mailer guys for building the first email queue
17
+ for Rails application.
18
+
19
+ This project is hosted at:
20
+ http://github.com/mauricio/resque_action_mailer_backend
21
+
22
+ You can find a blog post about it here:
23
+ http://codeshooter.wordpress.com/2010/07/28/asynchronous-email-deliveries-using-resque-and-resque_action_mailer_backend/
24
+
25
+ And you can also see a sample project using it here:
26
+ http://github.com/mauricio/resque_action_mailer_backend_example
27
+
28
+ This gem was tested with Ruby 1.8.7 and Rails 2.2.
29
+
30
+ == Note on Patches/Pull Requests
31
+
32
+ * Fork the project.
33
+ * Make your feature addition or bug fix.
34
+ * Add tests for it. This is important so I don't break it in a
35
+ future version unintentionally.
36
+ * Commit, do not mess with rakefile, version, or history.
37
+ (if you want to have your own version, that is fine but bump version in a
38
+ commit by itself I can ignore when I pull)
39
+ * Send me a pull request. Bonus points for topic branches.
40
+
41
+ == Copyright
42
+
43
+ Copyright (c) 2010 Maurício Linhares. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,64 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "resque_action_mailer_backend"
8
+ gem.summary = %Q{Use Resque to enqueue and send your emails}
9
+ gem.description = %Q{
10
+ With this gem you will be able to enqueue your emails
11
+ on your Resque workers to avoid making your user wait for the email to be
12
+ send when he causes an email sending action in your application.
13
+
14
+ Using resque_action_mailer_backend makes email sending a breeze as
15
+ you will be able to use Resque to retry failed emails, easily deliver all
16
+ those marketing emails to your clients and without changing anything at
17
+ your email sending code.
18
+
19
+ Just tell your application to use :resque for sending emails and you're done,
20
+ no need to add yet another tool just for delivering your emails if you're
21
+ already using Resque for your asynchronous processing.
22
+ }
23
+ gem.email = "mauricio.linhares@gmail.com"
24
+ gem.homepage = "http://github.com/mauricio/resque_action_mailer_backend"
25
+ gem.authors = ["Maurício Linhares"]
26
+ gem.rubyforge_project = 'resque_action_mailer_backend'
27
+
28
+ gem.add_dependency "resque", ">= 1.8.0"
29
+ gem.add_dependency 'actionmailer', '>= 2.2.0'
30
+ gem.add_development_dependency "rspec", ">= 1.2.9"
31
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
32
+ end
33
+ Jeweler::GemcutterTasks.new
34
+ rescue LoadError => ex
35
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
36
+ puts ex
37
+ puts ex.backtrace.join("\n")
38
+ end
39
+
40
+ require 'spec/rake/spectask'
41
+ Spec::Rake::SpecTask.new(:spec) do |spec|
42
+ spec.libs << 'lib' << 'spec'
43
+ spec.spec_files = FileList['spec/**/*_spec.rb']
44
+ end
45
+
46
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
47
+ spec.libs << 'lib' << 'spec'
48
+ spec.pattern = 'spec/**/*_spec.rb'
49
+ spec.rcov = true
50
+ end
51
+
52
+ task :spec => :check_dependencies
53
+
54
+ task :default => :spec
55
+
56
+ require 'rake/rdoctask'
57
+ Rake::RDocTask.new do |rdoc|
58
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
59
+
60
+ rdoc.rdoc_dir = 'rdoc'
61
+ rdoc.title = "resque_action_mailer_backend #{version}"
62
+ rdoc.rdoc_files.include('README*')
63
+ rdoc.rdoc_files.include('lib/**/*.rb')
64
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,53 @@
1
+
2
+ module Headbanger ; end
3
+
4
+ class Headbanger::ResqueMailer
5
+
6
+ @queue = :headbanger_resque_mailer
7
+
8
+ class << self
9
+
10
+ def queue
11
+ @queue
12
+ end
13
+
14
+ def queue=( new_queue )
15
+ @queue = new_queue
16
+ end
17
+
18
+ def deliver( mail )
19
+ mail.ready_to_send
20
+ Resque.enqueue(
21
+ Headbanger::ResqueMailer,
22
+ :destinations => mail.destinations,
23
+ :mail => mail.encoded,
24
+ :from => mail.from.first )
25
+ end
26
+
27
+ def perform( options )
28
+ new( options ).deliver
29
+ end
30
+
31
+ end
32
+
33
+ def initialize( options )
34
+ @options = options.symbolize_keys
35
+ end
36
+
37
+ def deliver
38
+ smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port])
39
+ smtp.enable_starttls_auto if smtp_settings[:enable_starttls_auto] && smtp.respond_to?(:enable_starttls_auto)
40
+ smtp.start(
41
+ smtp_settings[:domain],
42
+ smtp_settings[:user_name],
43
+ smtp_settings[:password],
44
+ smtp_settings[:authentication]) do |smtp|
45
+ smtp.sendmail(@options[:mail], @options[:sender], @options[:destinations])
46
+ end
47
+ end
48
+
49
+ def smtp_settings
50
+ ActionMailer::Base.smtp_settings
51
+ end
52
+
53
+ end
data/lib/init.rb ADDED
@@ -0,0 +1,2 @@
1
+
2
+ require 'resque_action_mailer_backend'
@@ -0,0 +1,11 @@
1
+ require 'action_mailer'
2
+ require 'resque'
3
+ require 'headbanger/resque_mailer'
4
+
5
+ ActionMailer::Base.class_eval do
6
+
7
+ def perform_delivery_resque(mail)
8
+ Headbanger::ResqueMailer.deliver( mail )
9
+ end
10
+
11
+ end
@@ -0,0 +1,80 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{resque_action_mailer_backend}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Maur\303\255cio Linhares"]
12
+ s.date = %q{2010-07-28}
13
+ s.description = %q{
14
+ With this gem you will be able to enqueue your emails
15
+ on your Resque workers to avoid making your user wait for the email to be
16
+ send when he causes an email sending action in your application.
17
+
18
+ Using resque_action_mailer_backend makes email sending a breeze as
19
+ you will be able to use Resque to retry failed emails, easily deliver all
20
+ those marketing emails to your clients and without changing anything at
21
+ your email sending code.
22
+
23
+ Just tell your application to use :resque for sending emails and you're done,
24
+ no need to add yet another tool just for delivering your emails if you're
25
+ already using Resque for your asynchronous processing.
26
+ }
27
+ s.email = %q{mauricio.linhares@gmail.com}
28
+ s.extra_rdoc_files = [
29
+ "LICENSE",
30
+ "README.rdoc"
31
+ ]
32
+ s.files = [
33
+ ".document",
34
+ ".gitignore",
35
+ "LICENSE",
36
+ "README.rdoc",
37
+ "Rakefile",
38
+ "VERSION",
39
+ "lib/headbanger/resque_mailer.rb",
40
+ "lib/init.rb",
41
+ "lib/resque_action_mailer_backend.rb",
42
+ "resque_action_mailer_backend.gemspec",
43
+ "spec/resque_action_mailer_backend_spec.rb",
44
+ "spec/spec.opts",
45
+ "spec/spec_helper.rb",
46
+ "spec/test_mailer.rb",
47
+ "spec/test_mailer/test.erb"
48
+ ]
49
+ s.homepage = %q{http://github.com/mauricio/resque_action_mailer_backend}
50
+ s.rdoc_options = ["--charset=UTF-8"]
51
+ s.require_paths = ["lib"]
52
+ s.rubyforge_project = %q{resque_action_mailer_backend}
53
+ s.rubygems_version = %q{1.3.7}
54
+ s.summary = %q{Use Resque to enqueue and send your emails}
55
+ s.test_files = [
56
+ "spec/resque_action_mailer_backend_spec.rb",
57
+ "spec/test_mailer.rb",
58
+ "spec/spec_helper.rb"
59
+ ]
60
+
61
+ if s.respond_to? :specification_version then
62
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_runtime_dependency(%q<resque>, [">= 1.8.0"])
67
+ s.add_runtime_dependency(%q<actionmailer>, [">= 2.2.0"])
68
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
69
+ else
70
+ s.add_dependency(%q<resque>, [">= 1.8.0"])
71
+ s.add_dependency(%q<actionmailer>, [">= 2.2.0"])
72
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
73
+ end
74
+ else
75
+ s.add_dependency(%q<resque>, [">= 1.8.0"])
76
+ s.add_dependency(%q<actionmailer>, [">= 2.2.0"])
77
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
78
+ end
79
+ end
80
+
@@ -0,0 +1,18 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "resque_action_mailer_backend" do
4
+
5
+ context 'on basic mailer calls' do
6
+
7
+ before do
8
+ ActionMailer::Base.delivery_method = :resque
9
+ end
10
+
11
+ it 'should send the email to resque on resque emails' do
12
+ Headbanger::ResqueMailer.should_receive(:deliver)
13
+ TestMailer.deliver_test
14
+ end
15
+
16
+ end
17
+
18
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ gem 'resque'
6
+ gem 'actionmailer'
7
+
8
+ require 'resque_action_mailer_backend'
9
+ require 'spec'
10
+ require 'spec/autorun'
11
+ require 'test_mailer'
@@ -0,0 +1,11 @@
1
+
2
+ class TestMailer < ActionMailer::Base
3
+
4
+ self.template_root = File.join( File.dirname(__FILE__) )
5
+
6
+ def test
7
+ recipients 'test@test.com'
8
+ from 'test@test.com'
9
+ end
10
+
11
+ end
@@ -0,0 +1 @@
1
+ This is a test.
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque_action_mailer_backend
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "Maur\xC3\xADcio Linhares"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-28 00:00:00 -03:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: resque
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 55
30
+ segments:
31
+ - 1
32
+ - 8
33
+ - 0
34
+ version: 1.8.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: actionmailer
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 7
46
+ segments:
47
+ - 2
48
+ - 2
49
+ - 0
50
+ version: 2.2.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 13
62
+ segments:
63
+ - 1
64
+ - 2
65
+ - 9
66
+ version: 1.2.9
67
+ type: :development
68
+ version_requirements: *id003
69
+ description: "\n With this gem you will be able to enqueue your emails\n on your Resque workers to avoid making your user wait for the email to be\n send when he causes an email sending action in your application.\n\n Using resque_action_mailer_backend makes email sending a breeze as\n you will be able to use Resque to retry failed emails, easily deliver all\n those marketing emails to your clients and without changing anything at\n your email sending code.\n\n Just tell your application to use :resque for sending emails and you're done,\n no need to add yet another tool just for delivering your emails if you're\n already using Resque for your asynchronous processing.\n "
70
+ email: mauricio.linhares@gmail.com
71
+ executables: []
72
+
73
+ extensions: []
74
+
75
+ extra_rdoc_files:
76
+ - LICENSE
77
+ - README.rdoc
78
+ files:
79
+ - .document
80
+ - .gitignore
81
+ - LICENSE
82
+ - README.rdoc
83
+ - Rakefile
84
+ - VERSION
85
+ - lib/headbanger/resque_mailer.rb
86
+ - lib/init.rb
87
+ - lib/resque_action_mailer_backend.rb
88
+ - resque_action_mailer_backend.gemspec
89
+ - spec/resque_action_mailer_backend_spec.rb
90
+ - spec/spec.opts
91
+ - spec/spec_helper.rb
92
+ - spec/test_mailer.rb
93
+ - spec/test_mailer/test.erb
94
+ has_rdoc: true
95
+ homepage: http://github.com/mauricio/resque_action_mailer_backend
96
+ licenses: []
97
+
98
+ post_install_message:
99
+ rdoc_options:
100
+ - --charset=UTF-8
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project: resque_action_mailer_backend
124
+ rubygems_version: 1.3.7
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Use Resque to enqueue and send your emails
128
+ test_files:
129
+ - spec/resque_action_mailer_backend_spec.rb
130
+ - spec/test_mailer.rb
131
+ - spec/spec_helper.rb