Created
November 23, 2011 17:26
-
-
Save temochka/1389288 to your computer and use it in GitHub Desktop.
Simple gist for fetching reply without quoted parts and signature from inbound message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ReplyParser | |
TEXT_PLAIN_SPLITTER = /^((> )?\/\/ ADD YOUR REPLY ABOVE$)|( *\-\-\-\-\- .+ \-\-\-\-\-)/ | |
class << self | |
def parse_reply_text(body) | |
splitter = TEXT_PLAIN_SPLITTER | |
prepare_reply_text(body.split(splitter).first) | |
end | |
private | |
def prepare_reply_text(text) | |
text.gsub!(/^>.*$/u, '') | |
text.strip | |
end | |
end | |
end | |
plain_text = <<BODY | |
This is reply text. | |
> // ADD YOUR REPLY ABOVE | |
> This is a quoted text | |
--- | |
User signature | |
BODY | |
puts ReplyParser.parse_reply_text(plain_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment