<commit_before>require 'net/smtp'
require 'date'

module Snoopit
  module Notifiers

    class Email < Snoopit::Notifier

      attr :smtp_server, :port, :tls

      def initialize(config=nil)
        super config, 'email'
      end

      def set_config(config)
        super config
        @smtp_server = @config['smtp-server']
        @port        = @config['port']
        @tls         = @config['tls']
        @user        = @config['user']
        @password    = @config['password']
      end

      def notify(found, notifier_params)
        send found, notifier_params['email']
      end

      def send(msg, notifier_params)
        begin
          auth = notifier_params['authentication'].nil? ? :login : notifier_params['authentication'].to_sym
          from = notifier_params['from'].nil? ? '<EMAIL>' : notifier_params['from']
          formatted = build_msg from, notifier_params['to'], msg
          smtp = Net::SMTP.new @smtp_server, @port
          smtp.enable_starttls_auto
          smtp.start @user.split('@')[1], @user, @password, auth do |smtp|
            smtp.send_message(formatted, from, notifier_params['to'])
          end
        rescue => e
          Snoopit.logger.warn e.message
          Snoopit.logger.warn e.backtrace
        end
      end

      def build_msg(from, to, msg)
        msg = <<-MSG
From: #{from}
To: #{to.kind_of(Array) ? to.join(', ') : to }
Content-Type: text/plain
Subject: #{msg[:comment]}
Date: #{DateTime.now.rfc822}

Snooper event on line: #{msg[:match_line_no]} in file: #{msg[:file]}

#{msg[:before].join('')}#{msg[:match]}#{msg[:after].join('')}
MSG
        msg
      end


    end
  end
end<commit_msg>Only join to when array<commit_after>require 'net/smtp'
require 'date'

module Snoopit
  module Notifiers

    class Email < Snoopit::Notifier

      attr :smtp_server, :port, :tls

      def initialize(config=nil)
        super config, 'email'
      end

      def set_config(config)
        super config
        @smtp_server = @config['smtp-server']
        @port        = @config['port']
        @tls         = @config['tls']
        @user        = @config['user']
        @password    = @config['password']
      end

      def notify(found, notifier_params)
        send found, notifier_params['email']
      end

      def send(msg, notifier_params)
        begin
          auth = notifier_params['authentication'].nil? ? :login : notifier_params['authentication'].to_sym
          from = notifier_params['from'].nil? ? '<EMAIL>' : notifier_params['from']
          formatted = build_msg from, notifier_params['to'], msg
          smtp = Net::SMTP.new @smtp_server, @port
          smtp.enable_starttls_auto
          smtp.start @user.split('@')[1], @user, @password, auth do |smtp|
            smtp.send_message(formatted, from, notifier_params['to'])
          end
        rescue => e
          Snoopit.logger.warn e.message
          Snoopit.logger.warn e.backtrace
        end
      end

      def build_msg(from, to, msg)
        msg = <<-MSG
From: #{from}
To: #{to.kind_of?(Array) ? to.join(', ') : to }
Content-Type: text/plain
Subject: #{msg[:comment]}
Date: #{DateTime.now.rfc822}

Snooper event on line: #{msg[:match_line_no]} in file: #{msg[:file]}

#{msg[:before].join('')}#{msg[:match]}#{msg[:after].join('')}
MSG
        msg
      end


    end
  end
end
{'fraction_non_alphanumeric': 0.14234342223554092, 'fraction_numerical': 0.00239736290080911, 'mean_word_length': 2.4447884416924666, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '6062289', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1071, 'n_words': 237}