lib/email_reply_parser.rb
# Splits the given text into a list of Fragments.  This is roughly done by
# reversing the text and parsing from the bottom to the top.  This way we
# can check for 'On <date>, <author> wrote:' lines above quoted blocks.
#
# text - A String email body.
# from_address - from address of the email (optional)
#
# Returns this same Email instance.
Splits the given text into a list of Fragments.  This is roughly done by
reversing the text and parsing from the bottom to the top.  This way we
can check for 'On ,  wrote:' lines above quoted blocks.

A String email body.
from_address - from address of the email (optional)

Returns this same Email instance.
Splits the given text into a list of Fragments . This is roughly done by reversing the text and parsing from the bottom to the top . This way we can check for ' On wrote : ' lines above quoted blocks . A String email body . from_address - from address of the email ( optional ) Returns this same Email instance .
def read(text, from_address = "")
      @from_name_raw = parse_raw_name_from_address(from_address)
      @from_name_normalized = normalize_name(@from_name_raw)
      @from_email = parse_email_from_address(from_address)
      text = normalize_text(text)
      text = text.reverse
      @found_visible = false
      @fragment = nil
      @scanner = StringScanner.new(text)
      while line = @scanner.scan_until(/\n/n)
        scan_line(line)
      end
      if (last_line = @scanner.rest.to_s).size > 0
        scan_line(last_line, true)
      end
      finish_fragment
      @scanner = @fragment = nil
      @fragments.reverse!
      self
    end
def read ( text , from_address = "" ) @from_name_raw = parse_raw_name_from_address ( from_address ) @from_name_normalized = normalize_name ( @from_name_raw ) @from_email = parse_email_from_address ( from_address ) text = normalize_text ( text ) text = text . reverse @found_visible = false @fragment = nil @scanner = StringScanner . new ( text ) while line = @scanner . scan_until ( / \n /n ) scan_line ( line ) end if ( last_line = @scanner . rest . to_s ) . size > 0 scan_line ( last_line , true ) end finish_fragment @scanner = @fragment = nil @fragments . reverse! self end
Splits the given text into a list of Fragments.
Splits the given text into a list of Fragments .
# parse out the from name if one exists and save for use later # The text is reversed initially due to the way we check for hidden # fragments. # This determines if any 'visible' Fragment has been found.  Once any # visible Fragment is found, stop looking for hidden ones. # This instance variable points to the current Fragment.  If the matched # line fits, it should be added to this Fragment.  Otherwise, finish it # and start a new Fragment. # Use the StringScanner to pull out each line of the email content. # Be sure to parse the last line of the email. # Finish up the final fragment.  Finishing a fragment will detect any # attributes (hidden, signature, reply), and join each line into a # string. # Now that parsing is done, reverse the order.
text
<not_specific>
from_address
<not_specific>