<commit_before>module Devtools
  # Abtract base class of tool configuration
  class Config

    # Declare raw accesors
    #
    # @api private
    #
    # @return [self]
    #
    def self.access(*names)
      names.each do |name|
        define_accessor(name)
      end
    end
    private_class_method :access

    # Define accessor
    #
    # @param [Symbol] name
    #
    # @return [self]
    #
    # @api private
    #
    def self.define_accessor(name)
      define_method(name) do
        raw.fetch(name.to_s)
      end
    end
    private_class_method :define_accessor

    # Return project
    #
    # @return [Project]
    #
    # @api private
    #
    attr_reader :project

    # Initialize object
    #
    # @return [Project]
    #
    # @api private
    #
    def initialize(project)
      @project = project
    end

    # Return config path
    #
    # @return [String]
    #
    # @api private
    #
    def config_file
      @config_file ||= project.config_dir.join(self.class::FILE).freeze
    end

    # Return raw data
    #
    # @return [Hash]
    #
    # @api private
    #
    def raw
      @raw ||= YAML.load_file(config_file).freeze
    end

    # Flay configuration
    class Flay < self
      FILE = 'flay.yml'.freeze
      access :total_score, :threshold
    end

    # Yardstick configuration
    class Yardstick < self
      FILE = 'yardstick.yml'.freeze
      access :threshold

      DEFAULT_THRESHOLD = 100

      DEFAULT_CONFIG = {
        'threshold' => DEFAULT_THRESHOLD
      }.freeze

      def raw
        @raw ||= File.exist?(config_file) ? yaml_config : DEFAULT_CONFIG
      end

      private

      def yaml_config<commit_msg>Make Config#raw private and add docs<commit_after>module Devtools
  # Abtract base class of tool configuration
  class Config

    # Declare raw accesors
    #
    # @api private
    #
    # @return [self]
    #
    def self.access(*names)
      names.each do |name|
        define_accessor(name)
      end
    end
    private_class_method :access

    # Define accessor
    #
    # @param [Symbol] name
    #
    # @return [self]
    #
    # @api private
    #
    def self.define_accessor(name)
      define_method(name) do
        raw.fetch(name.to_s)
      end
    end
    private_class_method :define_accessor

    # Return project
    #
    # @return [Project]
    #
    # @api private
    #
    attr_reader :project

    # Initialize object
    #
    # @return [Project]
    #
    # @api private
    #
    def initialize(project)
      @project = project
    end

    # Return config path
    #
    # @return [String]
    #
    # @api private
    #
    def config_file
      @config_file ||= project.config_dir.join(self.class::FILE).freeze
    end

    private

    # Return raw data
    #
    # @return [Hash]
    #
    # @api private
    #
    def raw
      @raw ||= YAML.load_file(config_file).freeze
    end

    # Flay configuration
    class Flay < self
      FILE = 'flay.yml'.freeze
      access :total_score, :threshold
    end

    # Yardstick configuration
    class Yardstick < self
      FILE = 'yardstick.yml'.freeze
      access :threshold

      DEFAULT_THRESHOLD = 100

      DEFAULT_CONFIG = {
        'threshold' => DEFAULT_THRESHOLD
      }.freeze

      private

      # Return raw data
      #
      # @return [Hash]
      #
      # @api private
      #
      def raw
        @raw ||= File.exist?(config_file) ? yaml_config : DEFAULT_CONFIG
      end

      # Return the raw config data from a yaml file
      #
      # @return [Hash]
      #
      # @api private
      #
      def yaml_config
{'fraction_non_alphanumeric': 0.08977209560867148, 'fraction_numerical': 0.0016675931072818232, 'mean_word_length': 1.838328075709779, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3588072', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1134, 'n_words': 273}