<commit_before>module GraphStarter
  class Configuration
    attr_writer :user_class

    def user_class
      @user_class || (:User if defined?(::User))
    end
  end
end

module GraphStarter
  CONFIG = Configuration.new

  def self.configure(config_hash = nil)
    if config_hash.nil?
      yield Configuration.new
    else
      config_hash.each do |key, value|
        CONFIG.send("#{key}=", value)
      end
    end
  end

  def self.configuration
    CONFIG
  end
end
<commit_msg>Add some configuration options and validate options when they are set<commit_after>module GraphStarter
  class Configuration
    attr_writer :user_class

    attr_accessor :menu_models, :icon_classes

    def initialize
      @icon_classes = {}
    end

    def user_class
      @user_class || (:User if defined?(::User))
    end

    def validation_errors
      {}.tap do |errors|
        if !(@menu_models.respond_to?(:each) || @menu_models.nil?)
          errors[:menu_models] = 'should be enumerable or nil'
        end

        if !@icon_classes.is_a?(Hash)
          errors[:icon_classes] = 'should be a Hash'
        end
      end
    end
  end
end

module GraphStarter
  CONFIG = Configuration.new

  def self.configure(config_hash = nil)
    if config_hash.nil?
      yield CONFIG
    else
      config_hash.each do |key, value|
        CONFIG.send("#{key}=", value)
      end
    end

    errors = CONFIG.validation_errors

    fail "GraphStarter validation errors: #{errors.inspect}" if errors.size > 0
  end

  def self.configuration
    CONFIG
  end
end

{'fraction_non_alphanumeric': 0.0849967804249839, 'fraction_numerical': 0.000643915003219575, 'mean_word_length': 2.630841121495327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '953906', 'n_tokens_mistral': 478, 'n_tokens_neox': 466, 'n_words': 134}