email_reply_trimmer 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b811566baddd01572925692005213b5c6818ddd
4
- data.tar.gz: f3bf620c832f78d05644e65ddcfc96def645d45e
3
+ metadata.gz: 6da75911e9abd808e0f27b0fe0207fb5cd2e6a7d
4
+ data.tar.gz: 0ff5da3a54857c4822579fb5f4489915558eb335
5
5
  SHA512:
6
- metadata.gz: 091e91ca51915f1c129b17774e69f314baa092d02cde3048fa8437250554d6cd37390c06b9693a37a8d9be6f6ee73ce690399d7530958e9d2178356b74458a89
7
- data.tar.gz: 86b8cffde68a6c8d7470b5514574733420afa908161087700aad494cd88fa32c232b03bc31607c166b57e7808cd3c8f109ddc25f0ef17c3e116e174b8f5e40b9
6
+ metadata.gz: 8002eea84ed92894029cd6a690405d9db0c40bd2249acaa19adcd51ba319d27c117e0e32a5a8ea0e231fadd1a85ba9283550c6e857a2e057182e9c86d3e5f823
7
+ data.tar.gz: 54165dc327a4425716f62c7bc0f21bacce2b4c29462bc5d801bd73938cc74b49de20e268dbd659cd443568284b810264f10599a24f569806466e6b6db2975239
@@ -6,7 +6,7 @@ require_relative "email_reply_trimmer/email_header_matcher"
6
6
  require_relative "email_reply_trimmer/quote_matcher"
7
7
 
8
8
  class EmailReplyTrimmer
9
- VERSION = "0.1.2"
9
+ VERSION = "0.1.3"
10
10
 
11
11
  DELIMITER = "d"
12
12
  EMBEDDED = "b"
@@ -34,8 +34,9 @@ class EmailReplyTrimmer
34
34
 
35
35
  # fix embedded email markers that might span over multiple lines
36
36
  EmbeddedEmailMatcher::ON_DATE_SOMEONE_WROTE_REGEXES.each do |r|
37
- next unless text =~ r
38
- text.gsub!($1, $1.gsub(/\n[[:space:]>\-]*/, " "))
37
+ if text =~ r
38
+ text.gsub!(r) { |m| m.gsub(/\n[[:space:]>\-]*/, " ") }
39
+ end
39
40
  end
40
41
 
41
42
  removed = []
@@ -2,8 +2,7 @@ On Mon, Feb 1, 2016 at 6:32 PM, Jeff Atwood <info@discourse.org> wrote:
2
2
 
3
3
  > This is Jeff's reply.
4
4
  >
5
- > On Mon, Feb 1, 2016 at 7:50 AM, Some One <foo@bar.com
6
- > > wrote:
5
+ > On Mon, Feb 1, 2016 at 7:50 AM, Some One <foo@bar.com wrote:
7
6
  >
8
7
  >> Great!
9
8
  >>
@@ -15,8 +14,7 @@ On Mon, Feb 1, 2016 at 6:32 PM, Jeff Atwood <info@discourse.org> wrote:
15
14
  >>
16
15
  >>> WAT?
17
16
  >>>
18
- >>> On Wed, Jan 27, 2016 at 10:48 PM, Some One <
19
- >>> foo@bar.com> wrote:
17
+ >>> On Wed, Jan 27, 2016 at 10:48 PM, Some One < foo@bar.com> wrote:
20
18
  >>>
21
19
  >>>> Hi Team,
22
20
  >>>>
@@ -24,8 +22,7 @@ On Mon, Feb 1, 2016 at 6:32 PM, Jeff Atwood <info@discourse.org> wrote:
24
22
  >>>>
25
23
  >>>> Some One
26
24
  >>>>
27
- >>>> On Wed, Jan 27, 2016 at 10:10 AM Discourse Team <team@discourse.org>
28
- >>>> wrote:
25
+ >>>> On Wed, Jan 27, 2016 at 10:10 AM Discourse Team <team@discourse.org> wrote:
29
26
  >>>>
30
27
  >>>>> Hello :waves_hand:
31
28
  >>>>>
@@ -0,0 +1,8 @@
1
+ On Thu, 31 Mar 2016 at 11:16 Some One < mailto:Some One <some.one@foo.bar> wrote:
2
+
3
+
4
+ Two 2
5
+
6
+ On Thu, 31 Mar 2016 at 10:05 Jeff Atwood < mailto:Jeff Atwood <team@discourse.org> wrote:
7
+
8
+ Three 3
@@ -0,0 +1,18 @@
1
+ One 1
2
+
3
+ On Thu, 31 Mar 2016 at 11:16 Some One
4
+
5
+ <
6
+ mailto:Some One <some.one@foo.bar>
7
+ > wrote:
8
+
9
+
10
+ Two 2
11
+
12
+ On Thu, 31 Mar 2016 at 10:05 Jeff Atwood
13
+
14
+ <
15
+ mailto:Jeff Atwood <team@discourse.org>
16
+ > wrote:
17
+
18
+ Three 3
@@ -8,19 +8,19 @@ class TestEmailReplyTrimmer < Minitest::Unit::TestCase
8
8
  ELIDED = Dir["test/elided/*.txt"].map { |path| File.basename(path) }
9
9
 
10
10
  def test_all_emails_have_a_matching_reply
11
- assert_equal EMAILS, TRIMMED, "Files in /emails and /trimmed folders should match 1-to-1."
12
- assert_equal EMAILS, ELIDED, "Files in /emails and /elided folders should match 1-to-1."
11
+ assert_equal(EMAILS, TRIMMED, "Files in /emails and /trimmed folders should match 1-to-1.")
12
+ assert_equal(EMAILS, ELIDED, "Files in /emails and /elided folders should match 1-to-1.")
13
13
  end
14
14
 
15
15
  def test_normalize_line_endings_email_has_windows_line_endings
16
- assert_match /\r\n/, File.read("test/emails/normalize_line_endings.txt")
16
+ assert_match(/\r\n/, File.read("test/emails/normalize_line_endings.txt"))
17
17
  end
18
18
 
19
19
  EMAILS.each do |filename|
20
20
  name = File.basename(filename, ".txt")
21
21
  define_method("test_#{name}") do
22
- assert_equal trim(filename), trimmed(filename), "[TRIMMED] EMAIL: #{filename}"
23
- assert_equal elide(filename), elided(filename), "[ELIDED] EMAIL: #{filename}"
22
+ assert_equal(trim(filename), trimmed(filename), "[TRIMMED] EMAIL: #{filename}")
23
+ assert_equal(elide(filename), elided(filename), "[ELIDED] EMAIL: #{filename}")
24
24
  end
25
25
  end
26
26
 
@@ -0,0 +1 @@
1
+ One 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_reply_trimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Régis Hanol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: EmailReplyTrimmer is a small library to trim replies from plain text
14
14
  email.
@@ -38,6 +38,7 @@ files:
38
38
  - test/elided/embedded_email_1.txt
39
39
  - test/elided/embedded_email_10.txt
40
40
  - test/elided/embedded_email_11.txt
41
+ - test/elided/embedded_email_12.txt
41
42
  - test/elided/embedded_email_2.txt
42
43
  - test/elided/embedded_email_3.txt
43
44
  - test/elided/embedded_email_4.txt
@@ -76,6 +77,7 @@ files:
76
77
  - test/emails/embedded_email_1.txt
77
78
  - test/emails/embedded_email_10.txt
78
79
  - test/emails/embedded_email_11.txt
80
+ - test/emails/embedded_email_12.txt
79
81
  - test/emails/embedded_email_2.txt
80
82
  - test/emails/embedded_email_3.txt
81
83
  - test/emails/embedded_email_4.txt
@@ -115,6 +117,7 @@ files:
115
117
  - test/trimmed/embedded_email_1.txt
116
118
  - test/trimmed/embedded_email_10.txt
117
119
  - test/trimmed/embedded_email_11.txt
120
+ - test/trimmed/embedded_email_12.txt
118
121
  - test/trimmed/embedded_email_2.txt
119
122
  - test/trimmed/embedded_email_3.txt
120
123
  - test/trimmed/embedded_email_4.txt