Class: Gitlab::Email::ReplyParser
- Inherits:
-
Object
- Object
- Gitlab::Email::ReplyParser
- Defined in:
- lib/gitlab/email/reply_parser.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(message, trim_reply: true) ⇒ ReplyParser
constructor
A new instance of ReplyParser.
Constructor Details
#initialize(message, trim_reply: true) ⇒ ReplyParser
Returns a new instance of ReplyParser.
9 10 11 12 |
# File 'lib/gitlab/email/reply_parser.rb', line 9 def initialize(, trim_reply: true) @message = @trim_reply = trim_reply end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message
7 8 9 |
# File 'lib/gitlab/email/reply_parser.rb', line 7 def @message end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gitlab/email/reply_parser.rb', line 14 def execute body = select_body() encoding = body.encoding if @trim_reply body = EmailReplyTrimmer.trim(body) end return '' unless body # not using /\s+$/ here because that deletes empty lines body = body.gsub(/[ \t]$/, '') # NOTE: We currently don't support empty quotes. # EmailReplyTrimmer allows this as a special case, # so we detect it manually here. return "" if body.lines.all? { |l| l.strip.empty? || l.start_with?('>') } body.force_encoding(encoding).encode("UTF-8") end |