<commit_before>require 'sitemapper/generator'
require 'sitemapper/sitemap'
require 'sitemapper/urlset'
require 'sitemapper/index'
require 'sitemapper/pinger'

module AegisNet
  module Sitemapper

    class Loader
      CONFIG_FILE = File.join(Rails.root, "config", "sitemaps.yml")
      # Loads the sitemap configuration from Rails.root/config/sitemap.yml
      def self.load_config
        # TODO verify file integrity
        erb = ERB.new(File.read(CONFIG_FILE))
        $sitemapper_config ||= HashWithIndifferentAccess.new(YAML.load(StringIO.new(erb.result)))
      end

      # Interprets +string+ as Ruby code representing a Proc and exectutes it.
      #
      # === Parameters
      # * +string+: Ruby (Proc) code to be executed
      # All other arguments will be passed to the Proc
      #
      # === Examples
      #  AegisNet::Sitemapper::Loader.proc_loader('Proc.new{"foo"}')
      #  => "foo"
      #
      #  proc_str = 'Proc.new{|n| n}'
      #  AegisNet::Sitemapper::Loader.proc_loader(proc_str, "hello world")
      #  => "hello world"
      def self.proc_loader(string, *args)
        # TODO lambdas
        eval(string).call(*args)
      end

    end
  end
end
<commit_msg>WIP: Get past undefined Rails.root<commit_after>require 'sitemapper/generator'
require 'sitemapper/sitemap'
require 'sitemapper/urlset'
require 'sitemapper/index'
require 'sitemapper/pinger'

module AegisNet
  module Sitemapper

    class Loader
      CONFIG_FILE = File.join(Rails.root.to_s, "config", "sitemaps.yml")
      # Loads the sitemap configuration from Rails.root/config/sitemap.yml
      def self.load_config
        # TODO verify file integrity
        erb = ERB.new(File.read(CONFIG_FILE))
        $sitemapper_config ||= HashWithIndifferentAccess.new(YAML.load(StringIO.new(erb.result)))
      end

      # Interprets +string+ as Ruby code representing a Proc and exectutes it.
      #
      # === Parameters
      # * +string+: Ruby (Proc) code to be executed
      # All other arguments will be passed to the Proc
      #
      # === Examples
      #  AegisNet::Sitemapper::Loader.proc_loader('Proc.new{"foo"}')
      #  => "foo"
      #
      #  proc_str = 'Proc.new{|n| n}'
      #  AegisNet::Sitemapper::Loader.proc_loader(proc_str, "hello world")
      #  => "hello world"
      def self.proc_loader(string, *args)
        # TODO lambdas
        eval(string).call(*args)
      end

    end
  end
end

{'fraction_non_alphanumeric': 0.1155758077879039, 'fraction_numerical': 0.0, 'mean_word_length': 2.827258320126783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4977272', 'n_tokens_mistral': 828, 'n_tokens_neox': 784, 'n_words': 176}