<commit_before>require 'set'
require File.dirname(__FILE__) + '/module_attribute_accessors'
require File.dirname(__FILE__) + '/core_ext/load_error'
require File.dirname(__FILE__) + '/core_ext/kernel'

module Dependencies #:nodoc:
  extend self

  # All files ever loaded.
  mattr_accessor :history
  self.history = Set.new

  # All files currently loaded.
  mattr_accessor :loaded
  self.loaded = Set.new

  # Should we load files or require them?
  mattr_accessor :mechanism
  self.mechanism = :load

  def load?
    mechanism == :load
  end

  def depend_on(file_name, swallow_load_errors = false)
    unless loaded.include?(file_name)
      begin
        require_or_load(file_name)
      rescue LoadError
        raise unless swallow_load_errors
      end
    end
  end

  def associate_with(file_name)
    depend_on(file_name, true)
  end

  def clear
    loaded.clear
  end

  def require_or_load(file_name)
    if load?
      # Append .rb if we have a bare file name.
      load_file_name = "#{file_name}.rb" unless file_name[-3..-1] == '.rb'

      # Enable warnings iff this file has not been loaded before.
      if history.include?(file_name)
        load load_file_name
      else
        enable_warnings { load load_file_name }
      end
    else
      require file_name
    end<commit_msg>Dependencies: set load_file_name = file_name if it ends in .rb<commit_after>require 'set'
require File.dirname(__FILE__) + '/module_attribute_accessors'
require File.dirname(__FILE__) + '/core_ext/load_error'
require File.dirname(__FILE__) + '/core_ext/kernel'

module Dependencies #:nodoc:
  extend self

  # All files ever loaded.
  mattr_accessor :history
  self.history = Set.new

  # All files currently loaded.
  mattr_accessor :loaded
  self.loaded = Set.new

  # Should we load files or require them?
  mattr_accessor :mechanism
  self.mechanism = :load

  def load?
    mechanism == :load
  end

  def depend_on(file_name, swallow_load_errors = false)
    unless loaded.include?(file_name)
      begin
        require_or_load(file_name)
      rescue LoadError
        raise unless swallow_load_errors
      end
    end
  end

  def associate_with(file_name)
    depend_on(file_name, true)
  end

  def clear
    loaded.clear
  end

  def require_or_load(file_name)
    if load?
      # Append .rb if we have a bare file name.
      load_file_name = (file_name =~ /\.rb$/ ? file_name : "#{file_name}.rb")

      # Enable warnings iff this file has not been loaded before.
      if history.include?(file_name)
        load load_file_name
      else
        enable_warnings { load load_file_name }
      end
    else
      require file_name
    end
{'fraction_non_alphanumeric': 0.07718373493975904, 'fraction_numerical': 0.0007530120481927711, 'mean_word_length': 2.9656716417910447, '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': '521891', 'n_tokens_mistral': 860, 'n_tokens_neox': 846, 'n_words': 235}