<commit_before>require 'feedjira'
require 'digest'
require 'mail'

module FeedjiraExtension
  AUTHOR_ATTRS = %i[name email uri]
  LINK_ATTRS = %i[href rel type hreflang title length]
  ENCLOSURE_ATTRS = %i[url type length]

  class Author < Struct.new(*AUTHOR_ATTRS)
    def to_json(options = nil)
      members.flat_map { |key|
        if value = self[key].presence
          case key
          when :email
            "<#{value}>"
          when :uri
            "(#{value})"
          else
            value
          end
        else
          []
        end
      }.join(' ').to_json(options)
    end
  end

  class AtomAuthor < Author
    include SAXMachine

    AUTHOR_ATTRS.each do |attr|
      element attr
    end
  end

  class RssAuthor < Author
    include SAXMachine

    def content=(content)
      @content = content

      begin
        addr = Mail::Address.new(content)
      rescue
        self.name = content
      else
        self.name = addr.name
        self.email = addr.address<commit_msg>Rescue error from Mail::Address#name and #address<commit_after>require 'feedjira'
require 'digest'
require 'mail'

module FeedjiraExtension
  AUTHOR_ATTRS = %i[name email uri]
  LINK_ATTRS = %i[href rel type hreflang title length]
  ENCLOSURE_ATTRS = %i[url type length]

  class Author < Struct.new(*AUTHOR_ATTRS)
    def to_json(options = nil)
      members.flat_map { |key|
        if value = self[key].presence
          case key
          when :email
            "<#{value}>"
          when :uri
            "(#{value})"
          else
            value
          end
        else
          []
        end
      }.join(' ').to_json(options)
    end
  end

  class AtomAuthor < Author
    include SAXMachine

    AUTHOR_ATTRS.each do |attr|
      element attr
    end
  end

  class RssAuthor < Author
    include SAXMachine

    def content=(content)
      @content = content

      begin
        addr = Mail::Address.new(content)
      rescue
        self.name = content
      else
        self.name = addr.name rescue nil
        self.email = addr.address rescue nil
{'fraction_non_alphanumeric': 0.08620689655172414, 'fraction_numerical': 0.0, 'mean_word_length': 1.9094707520891365, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5492511', 'n_tokens_mistral': 647, 'n_tokens_neox': 631, 'n_words': 174}