email_reply_parser 0.5.10 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/email_reply_parser.gemspec +2 -0
- data/lib/email_reply_parser.rb +3 -3
- data/test/email_reply_parser_test.rb +7 -0
- data/test/emails/email_2_3.txt +10 -0
- data/test/emails/email_long_quote.txt +16 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19456eb75469b983f8db4a0807f6691213264309223f37d02c7fcf44748e2d7c
|
4
|
+
data.tar.gz: 0a67068492fd8c2fe7221420e383f69f7ad0f6e7f435882830d8553e6f917bcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6b065c74ce3eec383d570824c3c22a0ff9fc1cbc17a99cbbac230a92a0eb9c90adcc96f6288891a676ff65da1a791d11b7c1a3cce9a22bacb3752c6fab6abf0
|
7
|
+
data.tar.gz: 72e65bff3a0850354268451e89ea352a8ab59c5bb8fe1c27ff7558df740ecd233915daaf5e35830a4c9c07617bc5ce6634a0c50aa5d3bd3464821c3328824e7e
|
data/email_reply_parser.gemspec
CHANGED
@@ -54,9 +54,11 @@ Gem::Specification.new do |s|
|
|
54
54
|
test/emails/email_1_8.txt
|
55
55
|
test/emails/email_2_1.txt
|
56
56
|
test/emails/email_2_2.txt
|
57
|
+
test/emails/email_2_3.txt
|
57
58
|
test/emails/email_BlackBerry.txt
|
58
59
|
test/emails/email_bullets.txt
|
59
60
|
test/emails/email_iPhone.txt
|
61
|
+
test/emails/email_long_quote.txt
|
60
62
|
test/emails/email_multi_word_sent_from_my_mobile_device.txt
|
61
63
|
test/emails/email_one_is_not_on.txt
|
62
64
|
test/emails/email_sent_from_my_not_signature.txt
|
data/lib/email_reply_parser.rb
CHANGED
@@ -30,7 +30,7 @@ require 'strscan'
|
|
30
30
|
#
|
31
31
|
# [mail]: https://github.com/mikel/mail
|
32
32
|
class EmailReplyParser
|
33
|
-
VERSION = "0.5.
|
33
|
+
VERSION = "0.5.11"
|
34
34
|
|
35
35
|
# Public: Splits an email body into a list of Fragments.
|
36
36
|
#
|
@@ -147,9 +147,9 @@ class EmailReplyParser
|
|
147
147
|
line.chomp!("\n")
|
148
148
|
line.lstrip! unless SIG_REGEX.match(line)
|
149
149
|
|
150
|
-
# We're looking for leading `>`
|
150
|
+
# We're looking for a leading `>` to see if this line is part of a
|
151
151
|
# quoted Fragment.
|
152
|
-
is_quoted = !!(line =~ /(
|
152
|
+
is_quoted = !!(line =~ /(>)$/)
|
153
153
|
|
154
154
|
# Mark the current Fragment as a signature if the current line is empty
|
155
155
|
# and the Fragment starts with a common signature indicator.
|
@@ -2,6 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'test/unit'
|
3
3
|
require 'pathname'
|
4
4
|
require 'pp'
|
5
|
+
require 'timeout'
|
5
6
|
|
6
7
|
dir = Pathname.new File.expand_path(File.dirname(__FILE__))
|
7
8
|
require dir + '..' + 'lib' + 'email_reply_parser'
|
@@ -222,6 +223,12 @@ I am currently using the Java HTTP API.\n", reply.fragments[0].to_s
|
|
222
223
|
assert_equal 1, reply.fragments.size
|
223
224
|
end
|
224
225
|
|
226
|
+
def test_long_quote_processing_completes
|
227
|
+
reply = Timeout.timeout(1) { email(:email_long_quote) }
|
228
|
+
|
229
|
+
assert_equal 5, reply.fragments.size
|
230
|
+
end
|
231
|
+
|
225
232
|
def email(name)
|
226
233
|
body = IO.read EMAIL_FIXTURE_PATH.join("#{name}.txt").to_s
|
227
234
|
EmailReplyParser.read body
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Outlook with a reply directly above line
|
2
|
+
|
3
|
+
From: CRM Comments [crm-comment@example.com]
|
4
|
+
Sent: Friday, 23 March 2012 5:08 p.m.
|
5
|
+
To: John S. Greene
|
6
|
+
Subject: [contact:106] John Greene
|
7
|
+
|
8
|
+
> A new comment has been added to the Contact named 'John Greene':
|
9
|
+
>
|
10
|
+
> I am replying to a comment.
|