action_mailer_verp 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/action_mailer_verp.gemspec +61 -0
- data/lib/action_mailer_verp.rb +33 -0
- data/spec/action_mailer_verp_spec.rb +57 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/templates/my_mailer/multiple_froms.erb +0 -0
- data/spec/templates/my_mailer/multiple_recipients.erb +0 -0
- data/spec/templates/my_mailer/some_mail.erb +0 -0
- metadata +113 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 James Golick
|
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,17 @@
|
|
1
|
+
= action_mailer_verp
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 James Golick. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "action_mailer_verp"
|
8
|
+
gem.summary = %Q{Send VERP emails with actionmailer.}
|
9
|
+
gem.description = %Q{Send VERP emails with actionmailer.}
|
10
|
+
gem.email = "jamesgolick@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/jamesgolick/action_mailer_verp"
|
12
|
+
gem.authors = ["James Golick"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_dependency "actionmailer", "~> 2.3.1"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
end
|
27
|
+
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "action_mailer_verp #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,61 @@
|
|
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{action_mailer_verp}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["James Golick"]
|
12
|
+
s.date = %q{2010-09-05}
|
13
|
+
s.description = %q{Send VERP emails with actionmailer.}
|
14
|
+
s.email = %q{jamesgolick@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"action_mailer_verp.gemspec",
|
27
|
+
"lib/action_mailer_verp.rb",
|
28
|
+
"spec/action_mailer_verp_spec.rb",
|
29
|
+
"spec/spec.opts",
|
30
|
+
"spec/spec_helper.rb",
|
31
|
+
"spec/templates/my_mailer/multiple_froms.erb",
|
32
|
+
"spec/templates/my_mailer/multiple_recipients.erb",
|
33
|
+
"spec/templates/my_mailer/some_mail.erb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/jamesgolick/action_mailer_verp}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.7}
|
39
|
+
s.summary = %q{Send VERP emails with actionmailer.}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/action_mailer_verp_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
+
s.add_runtime_dependency(%q<actionmailer>, ["~> 2.3.1"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
54
|
+
s.add_dependency(%q<actionmailer>, ["~> 2.3.1"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
58
|
+
s.add_dependency(%q<actionmailer>, ["~> 2.3.1"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'actionmailer'
|
2
|
+
|
3
|
+
module ActionMailerVerp
|
4
|
+
module FromRewriter
|
5
|
+
class MultipleFromsError < ArgumentError; end
|
6
|
+
class MultipleRecipientsError < ArgumentError; end
|
7
|
+
|
8
|
+
def self.included(klass)
|
9
|
+
klass.send(:alias_method_chain, :create_mail, :verp)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_mail_with_verp
|
13
|
+
create_mail_without_verp
|
14
|
+
verpify_from(@mail)
|
15
|
+
@mail
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def verpify_from(mail)
|
20
|
+
if mail.from_addrs.length > 1
|
21
|
+
raise MultipleFromsError, "Multiple from addresses not supported."
|
22
|
+
end
|
23
|
+
|
24
|
+
if mail.to.length > 1
|
25
|
+
raise MultipleRecipientsError, "Multiple recipients not supported."
|
26
|
+
end
|
27
|
+
|
28
|
+
from = mail.from_addrs.first
|
29
|
+
local = "#{from.local}+#{mail.to.first.gsub("@", "=")}"
|
30
|
+
mail.from = "#{from.name} <#{local}@#{from.domain}>"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "ActionMailerVerp" do
|
4
|
+
class MyMailer < ActionMailer::Base
|
5
|
+
include ActionMailerVerp::FromRewriter
|
6
|
+
self.template_root = File.dirname(__FILE__) + "/templates"
|
7
|
+
|
8
|
+
def some_mail(address)
|
9
|
+
from "MyCompany <donotreply@mycompany.com>"
|
10
|
+
recipients address
|
11
|
+
subject "An exciting new email from MyCompany"
|
12
|
+
end
|
13
|
+
|
14
|
+
def multiple_froms
|
15
|
+
from ["MyCompany <donotreply@mycompany.com>", "AnotherFrom <asdf@bsdf.com>"]
|
16
|
+
recipients "asdf@bsdf.com"
|
17
|
+
subject "An exciting new email from MyCompany"
|
18
|
+
end
|
19
|
+
|
20
|
+
def multiple_recipients
|
21
|
+
from "MyCompany <donotreply@mycompany.com>"
|
22
|
+
recipients ["asdf@bsdf.com", "bsdf@csdf.com"]
|
23
|
+
subject "An exciting new email from MyCompany"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "ActionMailerVerp::FromRewriter" do
|
28
|
+
describe "with one from address" do
|
29
|
+
before do
|
30
|
+
@mail = MyMailer.create_some_mail("james@example.com")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "rewrites the from address to be VERP compatible" do
|
34
|
+
addr = @mail.from_addrs.first
|
35
|
+
addr.local.should == "donotreply+james=example.com"
|
36
|
+
addr.domain.should == "mycompany.com"
|
37
|
+
addr.name.should == "MyCompany"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "with multiple from addresses" do
|
42
|
+
it "raises an error because that is not supported" do
|
43
|
+
lambda {
|
44
|
+
MyMailer.create_multiple_froms
|
45
|
+
}.should raise_error(ActionMailerVerp::FromRewriter::MultipleFromsError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "with multiple recipients" do
|
50
|
+
it "raises an error because that is not supported" do
|
51
|
+
lambda {
|
52
|
+
MyMailer.create_multiple_recipients
|
53
|
+
}.should raise_error(ActionMailerVerp::FromRewriter::MultipleRecipientsError)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
File without changes
|
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: action_mailer_verp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- James Golick
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-05 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 9
|
34
|
+
version: 1.2.9
|
35
|
+
type: :development
|
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: 1
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 3
|
49
|
+
- 1
|
50
|
+
version: 2.3.1
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description: Send VERP emails with actionmailer.
|
54
|
+
email: jamesgolick@gmail.com
|
55
|
+
executables: []
|
56
|
+
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files:
|
60
|
+
- LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
files:
|
63
|
+
- .document
|
64
|
+
- .gitignore
|
65
|
+
- LICENSE
|
66
|
+
- README.rdoc
|
67
|
+
- Rakefile
|
68
|
+
- VERSION
|
69
|
+
- action_mailer_verp.gemspec
|
70
|
+
- lib/action_mailer_verp.rb
|
71
|
+
- spec/action_mailer_verp_spec.rb
|
72
|
+
- spec/spec.opts
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
- spec/templates/my_mailer/multiple_froms.erb
|
75
|
+
- spec/templates/my_mailer/multiple_recipients.erb
|
76
|
+
- spec/templates/my_mailer/some_mail.erb
|
77
|
+
has_rdoc: true
|
78
|
+
homepage: http://github.com/jamesgolick/action_mailer_verp
|
79
|
+
licenses: []
|
80
|
+
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- --charset=UTF-8
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.3.7
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Send VERP emails with actionmailer.
|
111
|
+
test_files:
|
112
|
+
- spec/action_mailer_verp_spec.rb
|
113
|
+
- spec/spec_helper.rb
|