<commit_before>module Pear
  class Configuration
    CONFIG_FILE = '.pear.yml'

    attr_reader :authors, :email

    def write_sample_configuration
      abort('This doesn\'t look like a Git repository.') \
        unless Dir.exists?('.git')

      abort('Whoa there! A configuration file is already present.') \
        if File.exists?('.pear.yml')

      File.write(CONFIG_FILE, <<-config)
email: <EMAIL>
authors:
  - ad <NAME>
  - bd <NAME>
      config
    end

    def authors
      @authors ||= \
        configuration['authors'].each_with_object({}) do |author_data, hash|
          author = Author.new(author_data)
          hash[author.initials] = author.full_name
      end
    end

    def email
      @email ||= configuration['email']
    end

    private

    def configuration
      @configuration ||= YAML.load(File.open(CONFIG_FILE))
    end
  end

  class Author
    attr_reader :initials, :full_name

    def initialize(author_data)
      @initials, *full_name = author_data.split
      @full_name = full_name.join(' ')
    end<commit_msg>Refactor #write_sample_configuration.<commit_after>module Pear
  class Configuration
    CONFIG_FILE = '.pear.yml'

    attr_reader :authors, :email

    def write_sample_configuration
      ensure_git_repository_exists

      safeguard_pre_existing_configuration

      File.write(CONFIG_FILE, sample_configuration)
    end

    def authors
      @authors ||= \
        configuration['authors'].each_with_object({}) do |author_data, hash|
          author = Author.new(author_data)
          hash[author.initials] = author.full_name
      end
    end

    def email
      @email ||= configuration['email']
    end

    private

    def configuration
      @configuration ||= YAML.load(File.open(CONFIG_FILE))
    end

    def sample_configuration
      {
        email: '<EMAIL>',
        authors: [
          '<NAME>',
          'bd <NAME>'
        ]
      }.to_yaml
    end

    def ensure_git_repository_exists
      Dir.exists?('.git') or abort('This doesn\'t look like a Git repository.')
    end

    def safeguard_pre_existing_configuration
      File.exists?('.pear.yml') and abort('Configuration file already exists!')
    end
  end

  class Author
    attr_reader :initials, :full_name

    def initialize(author_data)
      @initials, *full_name = author_data.split
      @full_name = full_name.join(' ')
    end
{'fraction_non_alphanumeric': 0.10285474391267842, 'fraction_numerical': 0.0, 'mean_word_length': 2.578078078078078, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3796276', 'n_tokens_mistral': 735, 'n_tokens_neox': 698, 'n_words': 164}