action_mailer_verp 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{action_mailer_verp}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Golick"]
12
- s.date = %q{2010-09-05}
12
+ s.date = %q{2010-10-04}
13
13
  s.description = %q{Send VERP emails with actionmailer.}
14
14
  s.email = %q{jamesgolick@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,7 +25,10 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "action_mailer_verp.gemspec",
27
27
  "lib/action_mailer_verp.rb",
28
+ "lib/action_mailer_verp/bounce_processor.rb",
29
+ "lib/action_mailer_verp/pop_fetcher.rb",
28
30
  "spec/action_mailer_verp_spec.rb",
31
+ "spec/bounce_processor_spec.rb",
29
32
  "spec/spec.opts",
30
33
  "spec/spec_helper.rb",
31
34
  "spec/templates/my_mailer/multiple_froms.erb",
@@ -39,6 +42,7 @@ Gem::Specification.new do |s|
39
42
  s.summary = %q{Send VERP emails with actionmailer.}
40
43
  s.test_files = [
41
44
  "spec/action_mailer_verp_spec.rb",
45
+ "spec/bounce_processor_spec.rb",
42
46
  "spec/spec_helper.rb"
43
47
  ]
44
48
 
@@ -0,0 +1,14 @@
1
+ module ActionMailerVerp
2
+ class BounceProcessor
3
+ def initialize(fetcher)
4
+ @fetcher = fetcher
5
+ end
6
+
7
+ def each
8
+ @fetcher.each do |email|
9
+ local = email.to_addrs.first.local
10
+ yield local.split("+").last.gsub("=", "@")
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,31 @@
1
+ require 'net/pop'
2
+ require 'tmail/mail'
3
+
4
+ module ActionMailerVerp
5
+ class PopFetcher
6
+ include Enumerable
7
+
8
+ def initialize(host, username, password)
9
+ @host = host
10
+ @username = username
11
+ @password = password
12
+ end
13
+
14
+ def connection
15
+ if @connection.nil?
16
+ @connection = Net::POP3.new(@host)
17
+ @connection.start(@username, @password)
18
+ end
19
+
20
+ @connection
21
+ end
22
+
23
+ def each
24
+ connection.each_mail do |e|
25
+ yield TMail::Mail.parse(e.pop)
26
+ e.delete
27
+ end
28
+ connection.finish
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,6 @@
1
1
  require 'actionmailer'
2
+ require 'action_mailer_verp/bounce_processor'
3
+ require 'action_mailer_verp/pop_fetcher'
2
4
 
3
5
  module ActionMailerVerp
4
6
  module VERPMail
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe "BounceProcessor" do
4
+ class FakeFetcher
5
+ def initialize(*fetches)
6
+ @fetches = fetches
7
+ end
8
+
9
+ def each
10
+ @fetches.each { |f| yield f }
11
+ end
12
+ end
13
+
14
+ class Email < Struct.new(:to_addrs); end
15
+
16
+ class Address < Struct.new(:local); end
17
+
18
+ before do
19
+ @fetcher = FakeFetcher.new(Email.new([Address.new("donotreply+asdf=bsdf.com")]))
20
+ @processor = ActionMailerVerp::BounceProcessor.new(@fetcher)
21
+ end
22
+
23
+ it "yields the email address converted from VERP form to normal" do
24
+ yielded = []
25
+ @processor.each { |a| yielded << a }
26
+ yielded.should == ["asdf@bsdf.com"]
27
+ end
28
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_mailer_verp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
7
+ - 2
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ version: 0.2.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - James Golick
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-05 00:00:00 -07:00
17
+ date: 2010-10-04 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 13
30
28
  segments:
31
29
  - 1
32
30
  - 2
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 1
46
43
  segments:
47
44
  - 2
48
45
  - 3
@@ -68,7 +65,10 @@ files:
68
65
  - VERSION
69
66
  - action_mailer_verp.gemspec
70
67
  - lib/action_mailer_verp.rb
68
+ - lib/action_mailer_verp/bounce_processor.rb
69
+ - lib/action_mailer_verp/pop_fetcher.rb
71
70
  - spec/action_mailer_verp_spec.rb
71
+ - spec/bounce_processor_spec.rb
72
72
  - spec/spec.opts
73
73
  - spec/spec_helper.rb
74
74
  - spec/templates/my_mailer/multiple_froms.erb
@@ -88,7 +88,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
- hash: 3
92
91
  segments:
93
92
  - 0
94
93
  version: "0"
@@ -97,7 +96,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
96
  requirements:
98
97
  - - ">="
99
98
  - !ruby/object:Gem::Version
100
- hash: 3
101
99
  segments:
102
100
  - 0
103
101
  version: "0"
@@ -110,4 +108,5 @@ specification_version: 3
110
108
  summary: Send VERP emails with actionmailer.
111
109
  test_files:
112
110
  - spec/action_mailer_verp_spec.rb
111
+ - spec/bounce_processor_spec.rb
113
112
  - spec/spec_helper.rb