email_reply_parser 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/email_reply_parser.gemspec +2 -2
- data/lib/email_reply_parser.rb +10 -7
- metadata +4 -3
data/email_reply_parser.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'email_reply_parser'
|
16
|
-
s.version = '0.5.
|
17
|
-
s.date = '2012-
|
16
|
+
s.version = '0.5.1'
|
17
|
+
s.date = '2012-05-01'
|
18
18
|
s.rubyforge_project = 'email_reply_parser'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
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.1"
|
34
34
|
|
35
35
|
# Public: Splits an email body into a list of Fragments.
|
36
36
|
#
|
@@ -76,9 +76,12 @@ class EmailReplyParser
|
|
76
76
|
#
|
77
77
|
# Returns this same Email instance.
|
78
78
|
def read(text)
|
79
|
+
# in 1.9 we want to operate on the raw bytes
|
80
|
+
text = text.dup.force_encoding('binary') if text.respond_to?(:force_encoding)
|
81
|
+
|
79
82
|
# Check for multi-line reply headers. Some clients break up
|
80
83
|
# the "On DATE, NAME <EMAIL> wrote:" line into multiple lines.
|
81
|
-
if text =~ /^(On(.+)wrote:)$/
|
84
|
+
if text =~ /^(On(.+)wrote:)$/nm
|
82
85
|
# Remove all new lines from the reply header.
|
83
86
|
text.gsub! $1, $1.gsub("\n", " ")
|
84
87
|
end
|
@@ -98,7 +101,7 @@ class EmailReplyParser
|
|
98
101
|
|
99
102
|
# Use the StringScanner to pull out each line of the email content.
|
100
103
|
@scanner = StringScanner.new(text)
|
101
|
-
while line = @scanner.scan_until(/\n/)
|
104
|
+
while line = @scanner.scan_until(/\n/n)
|
102
105
|
scan_line(line)
|
103
106
|
end
|
104
107
|
|
@@ -121,8 +124,8 @@ class EmailReplyParser
|
|
121
124
|
|
122
125
|
private
|
123
126
|
EMPTY = "".freeze
|
124
|
-
SIG_REGEX = /(--|__|\w-$)|(^(\w+\s*){1,3} #{"Sent from my".reverse}$)/
|
125
|
-
|
127
|
+
SIG_REGEX = /(--|__|\w-$)|(^(\w+\s*){1,3} #{"Sent from my".reverse}$)/n
|
128
|
+
|
126
129
|
### Line-by-Line Parsing
|
127
130
|
|
128
131
|
# Scans the given line of text and figures out which fragment it belongs
|
@@ -137,7 +140,7 @@ class EmailReplyParser
|
|
137
140
|
|
138
141
|
# We're looking for leading `>`'s to see if this line is part of a
|
139
142
|
# quoted Fragment.
|
140
|
-
is_quoted = !!(line =~ /(>+)$/)
|
143
|
+
is_quoted = !!(line =~ /(>+)$/n)
|
141
144
|
|
142
145
|
# Mark the current Fragment as a signature if the current line is empty
|
143
146
|
# and the Fragment starts with a common signature indicator.
|
@@ -170,7 +173,7 @@ class EmailReplyParser
|
|
170
173
|
#
|
171
174
|
# Returns true if the line is a valid header, or false.
|
172
175
|
def quote_header?(line)
|
173
|
-
line =~ /^:etorw.*nO$/
|
176
|
+
line =~ /^:etorw.*nO$/n
|
174
177
|
end
|
175
178
|
|
176
179
|
# Builds the fragment string and reverses it, after all lines have been
|
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.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Long description. Maybe copied from the README.
|
15
15
|
email: technoweenie@gmail.com
|
@@ -59,9 +59,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
61
|
rubyforge_project: email_reply_parser
|
62
|
-
rubygems_version: 1.8.
|
62
|
+
rubygems_version: 1.8.10
|
63
63
|
signing_key:
|
64
64
|
specification_version: 2
|
65
65
|
summary: Short description used in Gem listings.
|
66
66
|
test_files:
|
67
67
|
- test/email_reply_parser_test.rb
|
68
|
+
has_rdoc:
|