<commit_before>module Constellation

  class ParseError < StandardError
    def initialize(file)
      super("Could not parse #{file}. Try overriding #parse_config_file")
    end
  end

  def self.enhance(klass)
    klass.extend Constellation::ClassMethods
    klass.env_params = {}
    klass.send :include, Constellation::InstanceMethods
  end

  module ClassMethods
    attr_accessor :env_params, :config_file, :load_from_gems
  end

  module InstanceMethods

    include Enumerable

    def initialize(data = nil)
      @data = {}
      indifferentize!
      reverse_merge(data || {})
      fall_back_on_env
      fall_back_on_file(Dir.pwd)
      fall_back_on_file(ENV['HOME'])
      fall_back_on_gems
    end

    def to_hash
      @data.dup
    end

    def [](key)
      @data[key.to_s]
    end
<commit_msg>don't rely on ActiveSupport's core extensions<commit_after>module Constellation

  class ParseError < StandardError
    def initialize(file)
      super("Could not parse #{file}. Try overriding #parse_config_file")
    end
  end

  def self.enhance(klass)
    klass.extend Constellation::ClassMethods
    klass.env_params = {}
    klass.send :include, Constellation::InstanceMethods
  end

  def self.hash_class
    @hash_class ||= begin
                      require 'active_support/hash_with_indifferent_access'
                      ActiveSupport::HashWithIndifferentAccess
                    rescue LoadError
                      Hash
                    end
  end

  module ClassMethods
    attr_accessor :env_params, :config_file, :load_from_gems
  end

  module InstanceMethods

    include Enumerable

    def initialize(data = nil)
      @data = Constellation.hash_class.new
      reverse_merge(data || {})
      fall_back_on_env
      fall_back_on_file(Dir.pwd)
      fall_back_on_file(ENV['HOME'])
      fall_back_on_gems
    end

    def to_hash
      @data.dup
    end

    def [](key)
      @data[key.to_s]
    end

{'fraction_non_alphanumeric': 0.07561728395061729, 'fraction_numerical': 0.0, 'mean_word_length': 2.5951940850277264, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4782866', 'n_tokens_mistral': 615, 'n_tokens_neox': 586, 'n_words': 127}