email_reply_parser 0.5.6 → 0.5.7

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.
@@ -76,6 +76,7 @@ Gem::Specification.new do |s|
76
76
  test/emails/email_1_5.txt
77
77
  test/emails/email_1_6.txt
78
78
  test/emails/email_1_7.txt
79
+ test/emails/email_1_8.txt
79
80
  test/emails/email_2_1.txt
80
81
  test/emails/email_2_2.txt
81
82
  test/emails/email_BlackBerry.txt
@@ -30,7 +30,7 @@ require 'strscan'
30
30
  #
31
31
  # [mail]: https://github.com/mikel/mail
32
32
  class EmailReplyParser
33
- VERSION = "0.5.6"
33
+ VERSION = "0.5.7"
34
34
 
35
35
  # Public: Splits an email body into a list of Fragments.
36
36
  #
@@ -84,7 +84,7 @@ class EmailReplyParser
84
84
 
85
85
  # Check for multi-line reply headers. Some clients break up
86
86
  # the "On DATE, NAME <EMAIL> wrote:" line into multiple lines.
87
- if text =~ /^(On\s(.+)wrote:)$/nm
87
+ if text =~ /^(On\s(.+?)wrote:)$/nm
88
88
  # Remove all new lines from the reply header.
89
89
  text.gsub! $1, $1.gsub("\n", " ")
90
90
  end
@@ -63,6 +63,26 @@ I am currently using the Java HTTP API.\n", reply.fragments[0].to_s
63
63
  assert_match /^_/, reply.fragments[5].to_s
64
64
  end
65
65
 
66
+ def test_reads_inline_replies
67
+ reply = email(:email_1_8)
68
+ assert_equal 7, reply.fragments.size
69
+
70
+ assert_equal [true, false, true, false, true, false, false],
71
+ reply.fragments.map { |f| f.quoted? }
72
+ assert_equal [false, false, false, false, false, false, true],
73
+ reply.fragments.map { |f| f.signature? }
74
+ assert_equal [false, false, false, false, true, true, true],
75
+ reply.fragments.map { |f| f.hidden? }
76
+
77
+ assert_match /^On [^\:]+\:/, reply.fragments[0].to_s
78
+ assert_match /^I will reply/, reply.fragments[1].to_s
79
+ assert_match "okay?", reply.fragments[2].to_s
80
+ assert_match /^and under this./, reply.fragments[3].to_s
81
+ assert_match /inline/, reply.fragments[4].to_s
82
+ assert_equal "\n", reply.fragments[5].to_s
83
+ assert_equal "--\nHey there, this is my signature\n", reply.fragments[6].to_s
84
+ end
85
+
66
86
  def test_recognizes_date_string_above_quote
67
87
  reply = email :email_1_4
68
88
 
@@ -0,0 +1,37 @@
1
+ On Tue, Apr 29, 2014 at 4:22 PM, Example Dev <sugar@example.com>wrote:
2
+
3
+ > okay. Well, here's some stuff I can write.
4
+ >
5
+ > And if I write a 2 second line you and maybe reply under this?
6
+ >
7
+ > Or if you didn't really feel like it, you could reply under this line.Or
8
+ > if you didn't really feel like it, you could reply under this line. Or if
9
+ > you didn't really feel like it, you could reply under this line. Or if you
10
+ > didn't really feel like it, you could reply under this line.
11
+ >
12
+
13
+ I will reply under this one
14
+
15
+ >
16
+ > okay?
17
+ >
18
+
19
+ and under this.
20
+
21
+ >
22
+ > -- Tim
23
+ >
24
+ > On Tue, April 29, 2014 at 4:21 PM, Tim Haines <tmhaines@example.com> wrote:
25
+ > > hi there
26
+ > >
27
+ > > After you reply to this I'm going to send you some inline responses.
28
+ > >
29
+ > > --
30
+ > > Hey there, this is my signature
31
+ >
32
+ >
33
+ >
34
+
35
+
36
+ --
37
+ Hey there, this is my signature
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_reply_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -33,6 +33,7 @@ files:
33
33
  - test/emails/email_1_5.txt
34
34
  - test/emails/email_1_6.txt
35
35
  - test/emails/email_1_7.txt
36
+ - test/emails/email_1_8.txt
36
37
  - test/emails/email_2_1.txt
37
38
  - test/emails/email_2_2.txt
38
39
  - test/emails/email_BlackBerry.txt