email_reply_parser 0.5.8 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/email_reply_parser.rb +6 -7
- data/test/email_reply_parser_test.rb +11 -0
- metadata +8 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 18ed91d7b72ad0b331359d9719a6f69f02366bdd
|
4
|
+
data.tar.gz: b97b2b17d548dfc86066001d936b49bf6035a0e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb73afe46d2313905f2cf542d5adf134439bed105922272f53bc6a1e93a3a786e2ab18445dcb0f6712c62251ef0a0632c8cdf1dca441b0d6b6413cd6b83cc8ba
|
7
|
+
data.tar.gz: 74370b59c92a813864096e4436c8c606bdc350d1ad43af12eded545d4eea38ea76764a98c5bbb3864ef813694f51eefb3895c3622cdd78844ebfff2354be32bf
|
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.9"
|
34
34
|
|
35
35
|
# Public: Splits an email body into a list of Fragments.
|
36
36
|
#
|
@@ -76,15 +76,14 @@ class EmailReplyParser
|
|
76
76
|
#
|
77
77
|
# Returns this same Email instance.
|
78
78
|
def read(text)
|
79
|
-
|
80
|
-
text = text.dup.force_encoding('binary') if text.respond_to?(:force_encoding)
|
79
|
+
text = text.dup
|
81
80
|
|
82
81
|
# Normalize line endings.
|
83
82
|
text.gsub!("\r\n", "\n")
|
84
83
|
|
85
84
|
# Check for multi-line reply headers. Some clients break up
|
86
85
|
# the "On DATE, NAME <EMAIL> wrote:" line into multiple lines.
|
87
|
-
if text =~ /^(?!On.*On\s.+?wrote:)(On\s(.+?)wrote:)$/
|
86
|
+
if text =~ /^(?!On.*On\s.+?wrote:)(On\s(.+?)wrote:)$/m
|
88
87
|
# Remove all new lines from the reply header.
|
89
88
|
text.gsub! $1, $1.gsub("\n", " ")
|
90
89
|
end
|
@@ -110,7 +109,7 @@ class EmailReplyParser
|
|
110
109
|
|
111
110
|
# Use the StringScanner to pull out each line of the email content.
|
112
111
|
@scanner = StringScanner.new(text)
|
113
|
-
while line = @scanner.scan_until(/\n/
|
112
|
+
while line = @scanner.scan_until(/\n/)
|
114
113
|
scan_line(line)
|
115
114
|
end
|
116
115
|
|
@@ -156,7 +155,7 @@ class EmailReplyParser
|
|
156
155
|
|
157
156
|
# We're looking for leading `>`'s to see if this line is part of a
|
158
157
|
# quoted Fragment.
|
159
|
-
is_quoted = !!(line =~ /(>+)$/
|
158
|
+
is_quoted = !!(line =~ /(>+)$/)
|
160
159
|
|
161
160
|
# Mark the current Fragment as a signature if the current line is empty
|
162
161
|
# and the Fragment starts with a common signature indicator.
|
@@ -189,7 +188,7 @@ class EmailReplyParser
|
|
189
188
|
#
|
190
189
|
# Returns true if the line is a valid header, or false.
|
191
190
|
def quote_header?(line)
|
192
|
-
line =~ /^:etorw.*nO$/
|
191
|
+
line =~ /^:etorw.*nO$/
|
193
192
|
end
|
194
193
|
|
195
194
|
# Builds the fragment string and reverses it, after all lines have been
|
@@ -9,6 +9,17 @@ require dir + '..' + 'lib' + 'email_reply_parser'
|
|
9
9
|
EMAIL_FIXTURE_PATH = dir + 'emails'
|
10
10
|
|
11
11
|
class EmailReplyParserTest < Test::Unit::TestCase
|
12
|
+
def test_encoding_should_be_maintained
|
13
|
+
body = IO.read EMAIL_FIXTURE_PATH.join("email_1_1.txt").to_s
|
14
|
+
EmailReplyParser.read body
|
15
|
+
reply = email(:email_1_1)
|
16
|
+
fragments = reply.fragments
|
17
|
+
refute_predicate fragments, :empty?
|
18
|
+
fragments.each do |fragment|
|
19
|
+
assert_equal body.encoding, fragment.to_s.encoding
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
def test_reads_simple_body
|
13
24
|
reply = email(:email_1_1)
|
14
25
|
assert_equal 3, reply.fragments.size
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_reply_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Rick Olson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Long description. Maybe copied from the README.
|
15
14
|
email: technoweenie@gmail.com
|
@@ -49,28 +48,28 @@ files:
|
|
49
48
|
- test/emails/pathological.txt
|
50
49
|
homepage: http://github.com/github/email_reply_parser
|
51
50
|
licenses: []
|
51
|
+
metadata: {}
|
52
52
|
post_install_message:
|
53
53
|
rdoc_options:
|
54
|
-
- --charset=UTF-8
|
54
|
+
- "--charset=UTF-8"
|
55
55
|
require_paths:
|
56
56
|
- lib
|
57
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
58
|
requirements:
|
60
|
-
- -
|
59
|
+
- - ">="
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '0'
|
63
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
63
|
requirements:
|
66
|
-
- -
|
64
|
+
- - ">="
|
67
65
|
- !ruby/object:Gem::Version
|
68
66
|
version: '0'
|
69
67
|
requirements: []
|
70
68
|
rubyforge_project: email_reply_parser
|
71
|
-
rubygems_version:
|
69
|
+
rubygems_version: 2.6.6
|
72
70
|
signing_key:
|
73
71
|
specification_version: 2
|
74
72
|
summary: Short description used in Gem listings.
|
75
73
|
test_files:
|
76
74
|
- test/email_reply_parser_test.rb
|
75
|
+
has_rdoc:
|