exjournal 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/exjournal.rb +3 -1
- data/spec/exjournal_spec.rb +12 -11
- data/spec/fixtures/email_with_references.eml +1 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/exjournal.rb
CHANGED
@@ -52,7 +52,7 @@ module Exjournal
|
|
52
52
|
# parse an address to a hash
|
53
53
|
def parse_address(address)
|
54
54
|
address = TMail::Address.parse(address) if address.is_a?(String)
|
55
|
-
{:name=>address.name, :
|
55
|
+
{:name=>address.name, :email_address=>address.address}
|
56
56
|
end
|
57
57
|
|
58
58
|
# parse one or more addresses to hash. failures result in a warning logged
|
@@ -77,6 +77,7 @@ module Exjournal
|
|
77
77
|
in_reply_to = strip_headers(mail.in_reply_to) if mail.in_reply_to
|
78
78
|
references = strip_headers(mail.references) if mail.references
|
79
79
|
from = parse_addresses(mail.from_addrs).first
|
80
|
+
sender = parse_addresses(mail.sender).first
|
80
81
|
to = parse_addresses(mail.to_addrs)
|
81
82
|
cc=parse_addresses(mail.cc_addrs)
|
82
83
|
bcc=parse_addresses(mail.bcc_addrs)
|
@@ -87,6 +88,7 @@ module Exjournal
|
|
87
88
|
:in_reply_to=>in_reply_to,
|
88
89
|
:references=>references,
|
89
90
|
:from=>from,
|
91
|
+
:sender=>sender,
|
90
92
|
:to=>to,
|
91
93
|
:cc=>cc,
|
92
94
|
:bcc=>bcc
|
data/spec/exjournal_spec.rb
CHANGED
@@ -69,28 +69,28 @@ Subject: i can't tell you
|
|
69
69
|
describe "parse_address" do
|
70
70
|
it "should extract a hash from an address" do
|
71
71
|
h = Exjournal.parse_address(TMail::Address.parse('"foo mcfoo" <foo@bar.com>'))
|
72
|
-
h.should == {:name=>"foo mcfoo", :
|
72
|
+
h.should == {:name=>"foo mcfoo", :email_address=>"foo@bar.com"}
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "parse_addresses" do
|
77
77
|
it "should extract a hash from a single address" do
|
78
78
|
h = Exjournal.parse_addresses(TMail::Address.parse('"foo mcfoo" <foo@bar.com>'))
|
79
|
-
h.should == [{:name=>"foo mcfoo", :
|
79
|
+
h.should == [{:name=>"foo mcfoo", :email_address=>"foo@bar.com"}]
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should extract hashes from more than one address" do
|
83
83
|
h = Exjournal.parse_addresses([TMail::Address.parse('"foo mcfoo" <foo@bar.com>'),
|
84
84
|
TMail::Address.parse('"baz mcbaz" <baz@boo.com>')])
|
85
|
-
h.should == [{:name=>"foo mcfoo", :
|
86
|
-
{:name=>"baz mcbaz", :
|
85
|
+
h.should == [{:name=>"foo mcfoo", :email_address=>"foo@bar.com"},
|
86
|
+
{:name=>"baz mcbaz", :email_address=>"baz@boo.com"}]
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should skip unparseable addresses and log a warning" do
|
90
90
|
mock(Exjournal.logger).warn(anything).times(2)
|
91
91
|
h = Exjournal.parse_addresses(['"foo mcfoo" <foo@bar.com>',
|
92
92
|
'"baz mcbaz" <<baz@boo.com>'])
|
93
|
-
h.should == [{:name=>"foo mcfoo", :
|
93
|
+
h.should == [{:name=>"foo mcfoo", :email_address=>"foo@bar.com"}]
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -105,9 +105,10 @@ Subject: i can't tell you
|
|
105
105
|
h[:references].should == ["B63CAA43-F378-4033-BA8B-foo@empire42.com",
|
106
106
|
"B63CAA43-F378-4033-BA8B-bar@empire42.com",
|
107
107
|
"B63CAA43-F378-4033-BA8B-baz@empire42.com"]
|
108
|
-
h[:from].should == {:name=>"Peter MacRobert", :
|
109
|
-
h[:
|
110
|
-
|
108
|
+
h[:from].should == {:name=>"Peter MacRobert", :email_address=>"peter.macrobert@empire42.com"}
|
109
|
+
h[:sender].should == {:name=>nil, :email_address=>"foo@bar.com"}
|
110
|
+
h[:to].should == [{:name=>nil, :email_address=>"foo@bar.com"},
|
111
|
+
{:name=>"bar mcbar", :email_address=>"bar.mcbar@bar.com"}]
|
111
112
|
h[:cc].should == []
|
112
113
|
h[:bcc].should == []
|
113
114
|
h[:subject].should == nil
|
@@ -123,9 +124,9 @@ Subject: i can't tell you
|
|
123
124
|
h[:references].should == ["B63CAA43-F378-4033-BA8B-foo@empire42.com",
|
124
125
|
"B63CAA43-F378-4033-BA8B-bar@empire42.com",
|
125
126
|
"B63CAA43-F378-4033-BA8B-baz@empire42.com"]
|
126
|
-
h[:from].should == {:name=>"Peter MacRobert", :
|
127
|
-
h[:to].should == [{:name=>nil, :
|
128
|
-
{:name=>"bar mcbar", :
|
127
|
+
h[:from].should == {:name=>"Peter MacRobert", :email_address=>"peter.macrobert@empire42.com"}
|
128
|
+
h[:to].should == [{:name=>nil, :email_address=>"foo@bar.com"},
|
129
|
+
{:name=>"bar mcbar", :email_address=>"bar.mcbar@bar.com"}]
|
129
130
|
h[:cc].should == []
|
130
131
|
h[:bcc].should == []
|
131
132
|
h[:subject].should == "Test email"
|
@@ -6,6 +6,7 @@ X-Apple-Base-Url: x-msg://1/
|
|
6
6
|
X-Universally-Unique-Identifier: c7cc15b2-7186-4f82-9936-894288fe9450
|
7
7
|
X-Apple-Mail-Remote-Attachments: YES
|
8
8
|
From: Peter MacRobert <peter.macrobert@empire42.com>
|
9
|
+
Sender: foo@bar.com
|
9
10
|
X-Apple-Windows-Friendly: 1
|
10
11
|
Date: Wed, 21 Apr 2010 14:43:24 +0100
|
11
12
|
Content-Transfer-Encoding: 7bit
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exjournal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Trampoline Systems Ltd
|