<commit_before># -*- coding: utf-8; mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- vim:fenc=utf-8:filetype=ruby:et:sw=2:ts=2:sts=2

require 'yaml'
require 'cgi'
require 'net/smtp'
require 'digest/sha1'

module GitCommitNotifier
  # Represents Git commit hook handler.
  class CommitHook

    class << self
      # Configuration that read from YAML file.
      # @return [Hash] Configuration.
      attr_reader :config

      # Prints error message to $stderr.
      # @param [String] message Message to be printed to $stderr.
      # @return [NilClass] nil
      def show_error(message)
        $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
        $stderr.puts "\n"
        $stderr.puts message
        $stderr.puts "\n"
        $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
        nil
      end

      # Prints informational message to $stdout.
      # @param [String] message Message to be printed to $stdout.
      # @return [NilClass] nil
      def info(message)
        $stdout.puts message
        $stdout.flush
        nil
      end

      # Gets logger.
      def logger
        @logger ||= Logger.new(config)
      end

      def is_email_address(email)
        email_regex = /\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/

        (email =~ email_regex)
      end

      def add_committer_to_recipient(recipient, committer_email)
        if is_email_address(committer_email) 
          recipient = "#{recipient},#{committer_email}"
        end

        recipient
      end
<commit_msg>Simplify email check<commit_after># -*- coding: utf-8; mode: ruby; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- vim:fenc=utf-8:filetype=ruby:et:sw=2:ts=2:sts=2

require 'yaml'
require 'cgi'
require 'net/smtp'
require 'digest/sha1'

module GitCommitNotifier
  # Represents Git commit hook handler.
  class CommitHook

    class << self
      # Configuration that read from YAML file.
      # @return [Hash] Configuration.
      attr_reader :config

      # Prints error message to $stderr.
      # @param [String] message Message to be printed to $stderr.
      # @return [NilClass] nil
      def show_error(message)
        $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
        $stderr.puts "\n"
        $stderr.puts message
        $stderr.puts "\n"
        $stderr.puts "************** GIT NOTIFIER PROBLEM *******************"
        nil
      end

      # Prints informational message to $stdout.
      # @param [String] message Message to be printed to $stdout.
      # @return [NilClass] nil
      def info(message)
        $stdout.puts message
        $stdout.flush
        nil
      end

      # Gets logger.
      def logger
        @logger ||= Logger.new(config)
      end

      def email?(email)
        !!(email =~ /@/)
      end

      def add_committer_to_recipient(recipient, committer_email)
        if email?(committer_email) 
          "#{recipient},#{committer_email}"
        else
          recipient
        end
      end

{'fraction_non_alphanumeric': 0.15063580045647212, 'fraction_numerical': 0.007173133355070101, 'mean_word_length': 2.3640350877192984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3209373', 'n_tokens_mistral': 994, 'n_tokens_neox': 963, 'n_words': 249}