<commit_before>module Munge
  class Bootstrap
    class << self
      def new_from_dir(root_path:)
        new_from_fs(
          root_path: root_path,
          config_path: config_path(root_path),
          setup_path: setup_path(root_path),
          rules_path: rules_path(root_path)
        )
      end

      def new_from_fs(root_path:,
                      config_path:,
                      setup_path:,
                      rules_path:)
        new(
          root_path: root_path,
          config: read_config(config_path),
          setup_string: File.read(setup_path),
          setup_path: setup_path,
          rules_string: File.read(rules_path),
          rules_path: rules_path
        )
      end

      private

      def read_config(config_path)
        Munge::Util::Config.read(config_path)
      end

      def config_path(root_path)
        File.join(root_path, "config.yml")
      end

      def setup_path(root_path)
        File.join(root_path, "setup.rb")
      end

      def rules_path(root_path)
        File.join(root_path, "rules.rb")
      end
    end

    def initialize(root_path:,
                   config:,
                   setup_string:,
                   rules_string:,
                   setup_path:,
                   rules_path:)
      system = Munge::System.new(root_path, config)

      binding.eval(setup_string, setup_path)

      @app = Munge::Application.new(system)

      binding.eval(rules_string, rules_path)
    end

    attr_reader :app
  end
end<commit_msg>create methods to easily access root/config paths<commit_after>module Munge
  class Bootstrap
    class << self
      def new_from_dir(root_path:)
        new_from_fs(
          root_path: root_path,
          config_path: config_path(root_path),
          setup_path: setup_path(root_path),
          rules_path: rules_path(root_path)
        )
      end

      def new_from_fs(root_path:,
                      config_path:,
                      setup_path:,
                      rules_path:)
        new(
          root_path: root_path,
          config: read_config(config_path),
          setup_string: File.read(setup_path),
          setup_path: setup_path,
          rules_string: File.read(rules_path),
          rules_path: rules_path
        )
      end

      private

      def read_config(config_path)
        Munge::Util::Config.read(config_path)
      end

      def config_path(root_path)
        File.join(root_path, "config.yml")
      end

      def setup_path(root_path)
        File.join(root_path, "setup.rb")
      end

      def rules_path(root_path)
        File.join(root_path, "rules.rb")
      end
    end

    def initialize(root_path:,
                   config:,
                   setup_string:,
                   rules_string:,
                   setup_path:,
                   rules_path:)
      @setup_path = setup_path
      @rules_path = rules_path

      system = Munge::System.new(root_path, config)

      binding.eval(setup_string, setup_path)

      @app = Munge::Application.new(system)

      binding.eval(rules_string, rules_path)
    end

    def root_path
      File.dirname(@setup_path)
    end

    def config_path
      File.join(root_path, "config")
    end

    attr_reader :app
  end
end
{'fraction_non_alphanumeric': 0.08113900796080833, 'fraction_numerical': 0.0, 'mean_word_length': 1.7592905405405406, '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': '1167003', 'n_tokens_mistral': 1021, 'n_tokens_neox': 969, 'n_words': 176}