Sha256: eb3b17d05c5ee493b090f1465f2610241a6a572557d140a44afca37e2ed42178
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true class EmailHeaderMatcher EMAIL_HEADERS_WITH_DATE_MARKERS = [ # Norwegian ["Sendt"], # English ["Sent", "Date"], # French ["Date", "Le"], # German ["Gesendet"], # Portuguese ["Enviada em"], # Spanish ["Enviado"], # Spanish (Mexican) ["Fecha"], # Italian ["Data"], # Dutch ["Datum"], # Swedish ["Skickat"], # Chinese ["发送时间"], ] EMAIL_HEADERS_WITH_DATE_REGEXES = EMAIL_HEADERS_WITH_DATE_MARKERS.map do |header| /^[[:blank:]*]*(?:#{header.join("|")})[[:blank:]*]*:.*\d+/ end EMAIL_HEADERS_WITH_TEXT_MARKERS = [ # Norwegian ["Fra", "Til", "Emne"], # English ["From", "To", "Cc", "Reply-To", "Subject"], # French ["De", "Expéditeur", "À", "Destinataire", "Répondre à", "Objet"], # German ["Von", "An", "Betreff"], # Portuguese ["De", "Para", "Assunto"], # Spanish ["De", "Para", "Asunto"], # Italian ["Da", "Risposta", "A", "Oggetto"], # Dutch ["Van", "Beantwoorden - Aan", "Aan", "Onderwerp"], # Swedish ["Från", "Till", "Ämne"], # Chinese ["发件人", "收件人", "主题"], ] EMAIL_HEADERS_WITH_TEXT_REGEXES = EMAIL_HEADERS_WITH_TEXT_MARKERS.map do |header| /^[[:blank:]*]*(?:#{header.join("|")})[[:blank:]*]*:.*[[:word:]]+/i end EMAIL_HEADER_REGEXES = [ EMAIL_HEADERS_WITH_DATE_REGEXES, EMAIL_HEADERS_WITH_TEXT_REGEXES, ].flatten def self.match?(line) EMAIL_HEADER_REGEXES.any? { |r| line =~ r } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
email_reply_trimmer-0.2.0 | lib/email_reply_trimmer/email_header_matcher.rb |