<commit_before>module Pod
  module TrunkApp
    class Owner < Sequel::Model
      self.dataset = :owners
      plugin :timestamps

      one_to_many :sessions, :class => 'Pod::TrunkApp::Session'

      def attributes
        values.inject({}) do |hash, (key, value)|
          hash[key.to_s] = value
          hash
        end
      end

      def public_attributes
        attributes
      end

      def to_yaml
        public_attributes.to_yaml
      end

      def self.normalize_email(email)
        email.to_s.strip.downcase
      end

      def self.find_or_create_by_email(email)
        email = normalize_email(email)
        if owner = where('email = ?', email).first
          owner
        else
          create(:email => email)
        end
      end

      def after_create
        super
        mail = Mail.new
        mail.from    '<EMAIL>'
        mail.to      email
        mail.subject 'This is a test email'
        mail.body    "Hi #{self.name}!"
        mail.deliver!<commit_msg>[Owner] Set charset of email to UTF-8.<commit_after>module Pod
  module TrunkApp
    class Owner < Sequel::Model
      self.dataset = :owners
      plugin :timestamps

      one_to_many :sessions, :class => 'Pod::TrunkApp::Session'

      def attributes
        values.inject({}) do |hash, (key, value)|
          hash[key.to_s] = value
          hash
        end
      end

      def public_attributes
        attributes
      end

      def to_yaml
        public_attributes.to_yaml
      end

      def self.normalize_email(email)
        email.to_s.strip.downcase
      end

      def self.find_or_create_by_email(email)
        email = normalize_email(email)
        if owner = where('email = ?', email).first
          owner
        else
          create(:email => email)
        end
      end

      def after_create
        super
        mail = Mail.new
        mail.charset = 'UTF-8'
        mail.from    = '<EMAIL>'
        mail.to      = email
        mail.subject = 'This is a test email'
        mail.body    = "Hi #{self.name}!"
        mail.deliver!
{'fraction_non_alphanumeric': 0.0876937984496124, 'fraction_numerical': 0.0009689922480620155, 'mean_word_length': 1.6679586563307494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '2804744', 'n_tokens_mistral': 623, 'n_tokens_neox': 601, 'n_words': 151}