<commit_before>require 'active_support/dependencies'

module RailsDevelopmentBoost
  module DependenciesPatch
    module LoadablePatch
      def require_dependency_with_constant_tracking(*args)
        ActiveSupport::Dependencies.required_dependency(args.first)
        # handle plugins such as concerned_with
        require_dependency_without_constant_tracking(*args)
      end
    end
    
    def self.apply!
      return if applied?
      
      # retain the original method in case the application overwrites it on its modules/klasses
      Module.send :alias_method, :_mod_name, :name
      
      patch = self
      ActiveSupport::Dependencies.module_eval do
        unless method_defined?(:local_const_defined?) # pre 4da45060 compatibility
          if method_defined?(:uninherited_const_defined?)
            alias_method :local_const_defined?, :uninherited_const_defined?
          else # post 4.0 compat
            def local_const_defined?(mod, const_name)
              mod.const_defined?(const_name, false)
            end
          end
        end
        remove_possible_method :remove_unloadable_constants!
        remove_possible_method :clear
        include patch
        alias_method_chain :load_file, 'constant_tracking'
        alias_method_chain :remove_constant, 'handling_of_connections'
        extend patch
        @routes_path_loading = nil
      end
      
      ActiveSupport::Dependencies::Loadable.module_eval do
        include LoadablePatch
        alias_method_chain :require_dependency, 'constant_tracking'
      end

      InstrumentationPatch.apply! if @do_instrument
      
      ActiveSupport::Dependencies.handle_already_autoloaded_constants!
    end
  
    def self.debug!
      if applied?
        InstrumentationPatch.apply!
      else
        @do_instrument = true
      end
    end
    
    def self.async=(new_value)
      @async = Async.process_new_async_value(new_value)
    end
    
    def self.async?
      @async
    end
    
    def self.enable_async_mode_by_default!
      Async.enable_by_default!(defined?(@async))
    end
    
    def self.applied?
      ActiveSupport::Dependencies < self
    end
    
    autoload :InstrumentationPatch, 'rails_development_boost/dependencies_patch/instrumentation_patch'
  
    mattr_accessor :explicit_dependencies
    self.explicit_dependencies = {}
    
    mattr_accessor :currently_loading
    self.currently_loading = []
    
    module Util
      extend self
      
      def anonymous_const?(mod)
        anonymous_const_name?(mod._mod_name)
      end
      
      def anonymous_const_name?(const_name)
        !const_name || const_name.empty?
      end
      
      def first_non_anonymous_superclass(klass)
        while (klass = klass.superclass) && anonymous_const?(klass); end
        klass
      end
      
      NOTHING = ''
      def in_autoloaded_namespace?(const_name) # careful, modifies passed in const_name!
        begin
          return true if LoadedFile.loaded_constant?(const_name)
        end while const_name.sub!(/::[^:]+\Z/, NOTHING)
        false
      end
      
      def load_path_to_real_path(path)
        expanded_path = File.expand_path(path)
        expanded_path << '.rb' unless path =~ /\.r(?:b|ake)\Z/
        expanded_path
      end
    end
    
    class ModuleCache
      def initialize
        @classes, @modules = [], []
        ObjectSpace.each_object(Module) {|mod| self << mod if relevant?(mod)}
        @singleton_ancestors = Hash.new {|h, klass| h[klass] = klass.singleton_class.ancestors}
      end
      
      def each_dependent_on(mod, &block)
        arr = []<commit_msg>Regexp check expanded_path (it is guaranteed to be a String).<commit_after>require 'active_support/dependencies'

module RailsDevelopmentBoost
  module DependenciesPatch
    module LoadablePatch
      def require_dependency_with_constant_tracking(*args)
        ActiveSupport::Dependencies.required_dependency(args.first)
        # handle plugins such as concerned_with
        require_dependency_without_constant_tracking(*args)
      end
    end
    
    def self.apply!
      return if applied?
      
      # retain the original method in case the application overwrites it on its modules/klasses
      Module.send :alias_method, :_mod_name, :name
      
      patch = self
      ActiveSupport::Dependencies.module_eval do
        unless method_defined?(:local_const_defined?) # pre 4da45060 compatibility
          if method_defined?(:uninherited_const_defined?)
            alias_method :local_const_defined?, :uninherited_const_defined?
          else # post 4.0 compat
            def local_const_defined?(mod, const_name)
              mod.const_defined?(const_name, false)
            end
          end
        end
        remove_possible_method :remove_unloadable_constants!
        remove_possible_method :clear
        include patch
        alias_method_chain :load_file, 'constant_tracking'
        alias_method_chain :remove_constant, 'handling_of_connections'
        extend patch
        @routes_path_loading = nil
      end
      
      ActiveSupport::Dependencies::Loadable.module_eval do
        include LoadablePatch
        alias_method_chain :require_dependency, 'constant_tracking'
      end

      InstrumentationPatch.apply! if @do_instrument
      
      ActiveSupport::Dependencies.handle_already_autoloaded_constants!
    end
  
    def self.debug!
      if applied?
        InstrumentationPatch.apply!
      else
        @do_instrument = true
      end
    end
    
    def self.async=(new_value)
      @async = Async.process_new_async_value(new_value)
    end
    
    def self.async?
      @async
    end
    
    def self.enable_async_mode_by_default!
      Async.enable_by_default!(defined?(@async))
    end
    
    def self.applied?
      ActiveSupport::Dependencies < self
    end
    
    autoload :InstrumentationPatch, 'rails_development_boost/dependencies_patch/instrumentation_patch'
  
    mattr_accessor :explicit_dependencies
    self.explicit_dependencies = {}
    
    mattr_accessor :currently_loading
    self.currently_loading = []
    
    module Util
      extend self
      
      def anonymous_const?(mod)
        anonymous_const_name?(mod._mod_name)
      end
      
      def anonymous_const_name?(const_name)
        !const_name || const_name.empty?
      end
      
      def first_non_anonymous_superclass(klass)
        while (klass = klass.superclass) && anonymous_const?(klass); end
        klass
      end
      
      NOTHING = ''
      def in_autoloaded_namespace?(const_name) # careful, modifies passed in const_name!
        begin
          return true if LoadedFile.loaded_constant?(const_name)
        end while const_name.sub!(/::[^:]+\Z/, NOTHING)
        false
      end
      
      def load_path_to_real_path(path)
        expanded_path = File.expand_path(path)
        expanded_path << '.rb' unless expanded_path =~ /\.r(?:b|ake)\Z/
        expanded_path
      end
    end
    
    class ModuleCache
      def initialize
        @classes, @modules = [], []
        ObjectSpace.each_object(Module) {|mod| self << mod if relevant?(mod)}
        @singleton_ancestors = Hash.new {|h, klass| h[klass] = klass.singleton_class.ancestors}
      end
      
      def each_dependent_on(mod, &block)
        arr = []
{'fraction_non_alphanumeric': 0.07134054498151444, 'fraction_numerical': 0.0021908804600848965, 'mean_word_length': 2.5302078298695023, 'pattern_counts': {'":': 0, '<': 13, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248091', 'n_tokens_mistral': 2137, 'n_tokens_neox': 2106, 'n_words': 429}