<commit_before>#encoding: UTF-8
require_relative './delivery.rb'
require_relative './configuration/configuration_error.rb'

class Configuration
  attr_reader :filename_prefix, :email_sender, :csv_filepath,
    :svg_filepath, :body_template_path, :inkscape_path, :cache_folder_path
  def initialize(options)
    @filename_prefix = options[:filename_prefix]
    @deliveries = Delivery.configure_deliveries(options[:deliveries])
    @email_sender = options[:deliveries][:sender]
    @csv_filepath = File.expand_path('data.csv', options[:data_folder])
    @svg_filepath = File.expand_path('model.svg', options[:data_folder])
    @body_template_path = File.expand_path('email.md.erb', options[:data_folder])
    @inkscape_path = options[:inkscape_path]
    @cache_folder_path = options[:cache_folder_path]

    if options[:data_folder].nil?
      raise ConfigurationError.new(options[:help])
    elsif @email_sender.nil?
      raise ConfigurationError.new("Missing SENDER information. Please define an environment variable with key name 'SENDER' or add that entry to your .env file.")
    elsif !@deliveries.first.complete?
      raise ConfigurationError.new(@deliveries.first.error_messages)
    end
  end
  def delivery
    @deliveries.first
  end
end
<commit_msg>Small refactoring in the configuration<commit_after>#encoding: UTF-8
require_relative './delivery.rb'
require_relative './configuration/configuration_error.rb'

class Configuration
  attr_reader :filename_prefix, :delivery, :email_sender, :csv_filepath,
    :svg_filepath, :body_template_path, :inkscape_path, :cache_folder_path
  def initialize(options)
    @filename_prefix = options[:filename_prefix]
    @delivery = Delivery.configure_deliveries(options[:deliveries]).first
    @email_sender = options[:deliveries][:sender]
    @csv_filepath = File.expand_path('data.csv', options[:data_folder])
    @svg_filepath = File.expand_path('model.svg', options[:data_folder])
    @body_template_path = File.expand_path('email.md.erb', options[:data_folder])
    @inkscape_path = options[:inkscape_path]
    @cache_folder_path = options[:cache_folder_path]

    raise_error_if_incomplete(options)
  end
  private
  def raise_error_if_incomplete(options)
    if options[:data_folder].nil?
      raise ConfigurationError.new(options[:help])
    elsif @email_sender.nil?
      raise ConfigurationError.new("Missing SENDER information. Please define an environment variable with key name 'SENDER' or add that entry to your .env file.")
    elsif !@delivery.complete?
      raise ConfigurationError.new(@delivery.error_messages)
    end
  end
end

{'fraction_non_alphanumeric': 0.10657945363601386, 'fraction_numerical': 0.0007695267410542517, 'mean_word_length': 5.451612903225806, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6051692', 'n_tokens_mistral': 791, 'n_tokens_neox': 790, 'n_words': 156}