Class: EmailReplyParser
- Inherits:
-
Object
- Object
- EmailReplyParser
- Defined in:
- lib/email_reply_parser/email_reply_parser.rb
Overview
EmailReplyParser is a small library to parse plain text email content. The goal is to identify which fragments are quoted, part of a signature, or original body content. We want to support both top and bottom posters, so no simple “REPLY ABOVE HERE” content is used.
Beyond RFC 5322 (which is handled by the [Ruby mail gem]), there aren’t any real standards for how emails are created. This attempts to parse out common conventions for things like replies:
this is some text
On <date>, <author> wrote:
> blah blah
> blah blah
… and signatures:
this is some text
--
Bob
http://homepage.com/~bob
Each of these are parsed into Fragment objects.
EmailReplyParser also attempts to figure out which of these blocks should be hidden from users.
Defined Under Namespace
Class Method Summary collapse
- .parse_new_content(text, from_address = "") ⇒ Object
-
.parse_reply(text, from_address = "") ⇒ Object
Public: Get the text of the visible portions of the given email body.
-
.read(text, from_address = "") ⇒ Object
Public: Splits an email body into a list of Fragments.
Class Method Details
.parse_new_content(text, from_address = "") ⇒ Object
53 54 55 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 53 def self.parse_new_content(text, from_address = "") self.read(text, from_address).new_content end |
.parse_reply(text, from_address = "") ⇒ Object
Public: Get the text of the visible portions of the given email body.
text - A String email body. from_address - from address of the email (optional)
Returns a String.
49 50 51 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 49 def self.parse_reply(text, from_address = "") self.read(text.to_s, from_address).visible_text end |
.read(text, from_address = "") ⇒ Object
Public: Splits an email body into a list of Fragments.
text - A String email body. from_address - from address of the email (optional)
Returns an Email instance.
39 40 41 |
# File 'lib/email_reply_parser/email_reply_parser.rb', line 39 def self.read(text, from_address = "") Email.new.read(text, from_address) end |