<commit_before>module Merb
  
  def self.start
    BootLoader.run
  end
  
  class BootLoader
    
    cattr_accessor :subclasses
    class_inheritable_accessor :after, :before
    
    class << self
      
      def inherited(klass)
        unless klass.before || klass.after
          subclasses << klass.to_s
        elsif klass.before
          subclasses.insert(subclasses.index(klass.before), klass)
        else
          subclasses.insert(subclasses.index(klass.before) + 1, klass)          
        end
        super
      end
      
      def run
        subclasses.each {|klass| klass.new.run! }
      end
      
      def after(klass)
        after = klass
      end
      
      def before(klass)
        before = klass
      end
      
    end
    
  end
  
end

class Merb::BootLoader::BuildFramework < Merb::BootLoader
  def run
    build_framework
  end
  
  # This method should be overridden in merb_init.rb before Merb.start to set up a different
  # framework structure
  def build_framework
    %[view model controller helper mailer part].each do |component|
      Merb.push_path(component.to_sym, Merb.root_path "app/#{component}s")
    end
    Merb.push_path(:app_controller, Merb.root_path "app/controllers", "application_controller.rb")
    Merb.push_path(:config,         Merb.root_path "config", "router.rb")
    Merb.push_path(:lib,            Merb.root_path "lib")    
  end
end

class Merb::BootLoader::LoadPaths < Merb::BootLoader
  LOADED_CLASSES = {}
  
  def run
    # Add models, controllers, and lib to the load path
    $LOAD_PATH.unshift Merb.load_paths[:model].first      if Merb.load_paths[:model]
    $LOAD_PATH.unshift Merb.load_paths[:controller].first if Merb.load_paths[:controller]
    $LOAD_PATH.unshift Merb.load_paths[:lib].first        if Merb.load_paths[:lib]
    
    # Require all the files in the registered load paths
    Merb.load_paths.each do |name, path|
      Dir[path.first / path.last].each do |file| 
        klasses = ObjectSpace.classes.dup
        require f
        LOADED_CLASSES[file] = ObjectSpace.classes - klasses
      end
    end
  end

  def reload(file)
    if klasses = LOADED_CLASSES[file]
      klasses.each do |klass|
        remove_constant(klass)
      end
    end
  end
  
  def remove_constant(const)
    # This is to support superclasses (like AbstractController) that track
    # their subclasses in a class variable. Classes that wish to use this
    # functionality are required to alias it to _subclasses_list. Plugins
    # for ORMs and other libraries should keep this in mind.
    if klass.superclass.respond_to?(:_subclasses_list)
      klass.superclass.send(:_subclasses_list).delete(klass)<commit_msg>Whoops... Reloading needs to actually reload the file :P<commit_after>module Merb
  
  def self.start
    BootLoader.run
  end
  
  class BootLoader
    
    cattr_accessor :subclasses
    class_inheritable_accessor :after, :before
    
    class << self
      
      def inherited(klass)
        unless klass.before || klass.after
          subclasses << klass.to_s
        elsif klass.before
          subclasses.insert(subclasses.index(klass.before), klass)
        else
          subclasses.insert(subclasses.index(klass.before) + 1, klass)          
        end
        super
      end
      
      def run
        subclasses.each {|klass| klass.new.run! }
      end
      
      def after(klass)
        after = klass
      end
      
      def before(klass)
        before = klass
      end
      
    end
    
  end
  
end

class Merb::BootLoader::BuildFramework < Merb::BootLoader
  def run
    build_framework
  end
  
  # This method should be overridden in merb_init.rb before Merb.start to set up a different
  # framework structure
  def build_framework
    %[view model controller helper mailer part].each do |component|
      Merb.push_path(component.to_sym, Merb.root_path "app/#{component}s")
    end
    Merb.push_path(:app_controller, Merb.root_path "app/controllers", "application_controller.rb")
    Merb.push_path(:config,         Merb.root_path "config", "router.rb")
    Merb.push_path(:lib,            Merb.root_path "lib")    
  end
end

class Merb::BootLoader::LoadPaths < Merb::BootLoader
  LOADED_CLASSES = {}
  
  def run
    # Add models, controllers, and lib to the load path
    $LOAD_PATH.unshift Merb.load_paths[:model].first      if Merb.load_paths[:model]
    $LOAD_PATH.unshift Merb.load_paths[:controller].first if Merb.load_paths[:controller]
    $LOAD_PATH.unshift Merb.load_paths[:lib].first        if Merb.load_paths[:lib]
    
    # Require all the files in the registered load paths
    Merb.load_paths.each do |name, path|
      Dir[path.first / path.last].each do |file| 
        klasses = ObjectSpace.classes.dup
        require f
        LOADED_CLASSES[file] = ObjectSpace.classes - klasses
      end
    end
  end

  def reload(file)
    if klasses = LOADED_CLASSES[file]
      klasses.each do |klass|
        remove_constant(klass)
      end
    end
    load file
  end
  
  def remove_constant(const)
    # This is to support superclasses (like AbstractController) that track
    # their subclasses in a class variable. Classes that wish to use this
    # functionality are required to alias it to _subclasses_list. Plugins
    # for ORMs and other libraries should keep this in mind.
    if klass.superclass.respond_to?(:_subclasses_list)
      klass.superclass.send(:_subclasses_list).delete(klass)
{'fraction_non_alphanumeric': 0.08038172141677372, 'fraction_numerical': 0.00036703982382088455, 'mean_word_length': 2.5343709468223086, 'pattern_counts': {'":': 0, '<': 15, '<?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': '3808524', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1696, 'n_words': 435}