<commit_before>module ACLS
  class Loader
    class << self
      # Use one or more paths to autoload a set of Ruby source files.
      def auto(paths, opts={})
        opts = default_opts.merge(opts)
        trees = build_trees(paths, opts)
        autoload_magic(trees, opts)
      end

      def default_opts
        {root_ns: false, exclude: [], immediate: []}
      end

      private

      def build_trees(paths, opts)
        if paths.respond_to?(:each)
          paths.map { |path| build_tree(path, opts) }
        else
          [build_tree(paths, opts)]
        end
      end

      def build_tree(path, opts)
        Parser.parse(path)
      end

      def autoload_statement(tree)
        "autoload :#{tree.name}, \"#{tree.source}\""
      end

      def autoload_root(tree, opts)
          root = Object
          if opts[:root_ns].is_a?(TrueClass)
            root = submodule(root, File.basename(tree.directory).camelize)
          elsif opts[:root_ns].is_a?(String)
            opts[:root_ns].split('::').each { |ns| root = submodule(root, ns) }
          end
          root
      end

      def autoload_magic(trees, opts)
        trees.map do |tree|
          root = autoload_root(tree, opts)
          tree.children.map do |node|
            autoload_tree(root, node, opts)
          end
        end
      end

      def autoload_tree(mod, tree, opts)
        unless exclude?(mod, tree, opts)
          if tree.source
            mod.module_eval(autoload_statement(tree))
          else
            sub = submodule(mod, tree.name)
            tree.children.map { |child| autoload_tree(sub, child, opts) }
          end
        end
      end<commit_msg>Cleanup on the autoload function names/invocations<commit_after>module ACLS
  class Loader
    class << self
      # Use one or more paths to autoload a set of Ruby source files.
      def auto(paths, opts={})
        opts = default_opts.merge(opts)
        autoload_trees(build_trees(paths, opts), opts)
      end

      def default_opts
        {root_ns: false, exclude: [], immediate: []}
      end

      private

      def build_trees(paths, opts)
        if paths.respond_to?(:each)
          paths.map { |path| build_tree(path, opts) }
        else
          [build_tree(paths, opts)]
        end
      end

      def build_tree(path, opts)
        Parser.parse(path)
      end

      def autoload_statement(tree)
        "autoload :#{tree.name}, \"#{tree.source}\""
      end

      def autoload_root(tree, opts)
          root = Object
          if opts[:root_ns].is_a?(TrueClass)
            root = submodule(root, File.basename(tree.directory).camelize)
          elsif opts[:root_ns].is_a?(String)
            opts[:root_ns].split('::').each { |ns| root = submodule(root, ns) }
          end
          root
      end

      def autoload_trees(trees, opts)
        trees.map do |tree|
          root = autoload_root(tree, opts)
          tree.children.map do |node|
            autoload_tree(root, node, opts)
          end
        end
      end

      def autoload_tree(mod, tree, opts)
        unless exclude?(mod, tree, opts)
          if tree.source
            mod.module_eval(autoload_statement(tree))
          else
            sub = submodule(mod, tree.name)
            tree.children.map { |child| autoload_tree(sub, child, opts) }
          end
        end
      end
{'fraction_non_alphanumeric': 0.10360226257814825, 'fraction_numerical': 0.0, 'mean_word_length': 1.847457627118644, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7105469', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1031, 'n_words': 250}