lib/email_reply_parser.rb
# Scans the given line of text and determines which fragment it belongs to.
Scans the given line of text and determines which fragment it belongs to.
Scans the given line of text and determines which fragment it belongs to .
def scan_line(line, last = false)
      line.chomp!("\n")
      line.reverse!
      line.rstrip!
      scan_signature_or_quote if @fragment && line == EMPTY
      is_quoted = !!(line =~ /^>+/n)
      unless @fragment &&
          ((@fragment.quoted? == is_quoted) ||
           (@fragment.quoted? && (line_is_reply_header?(line) || line == EMPTY)))
        finish_fragment
        @fragment = Fragment.new
        @fragment.quoted = is_quoted
      end
      @fragment.add_line(line)
      scan_signature_or_quote if last
    end
def scan_line ( line , last = false ) line . chomp! ( "\n" ) line . reverse! line . rstrip! scan_signature_or_quote if @fragment && line == EMPTY is_quoted = ! ! ( line =~ / ^>+ /n ) unless @fragment && ( ( @fragment . quoted? == is_quoted ) || ( @fragment . quoted? && ( line_is_reply_header? ( line ) || line == EMPTY ) ) ) finish_fragment @fragment = Fragment . new @fragment . quoted = is_quoted end @fragment . add_line ( line ) scan_signature_or_quote if last end
Scans the given line of text and determines which fragment it belongs to.
Scans the given line of text and determines which fragment it belongs to .
# Mark the current Fragment as a signature if the current line is empty # and the Fragment starts with a common signature indicator. # Mark the current Fragment as a quote if the current line is empty # and the Fragment starts with a multiline quote header. # We're looking for leading `>`'s to see if this line is part of a # quoted Fragment. # Note that a common reply header also counts as part of the quoted # Fragment, even though it doesn't start with `>`.
line
<not_specific>
last
<not_specific>