<commit_before># -*- encoding: utf-8 -*-

require 'yaml'

module Coco

  # Public: I know the configuration of coco.
  # You can override the default configuration by putting a '.coco.yml'
  # file in YAML format in the project root directory.
  #
  # Examples
  #
  #   # Read the threshold value
  #   config = Configuration.new
  #   config[:threshold]
  #   # => 100
  #
  #   # To override the threshold, put this line in '.coco.yml' file:
  #   # :threshold: 70
  #
  # Note you can set the threshold above 100% (to be sure to see all
  # files) but you cannot set it under 0.
  class Configuration < Hash

    # Public: Initialize a Configuration.
    def initialize
      self[:threshold] = 100
      self[:directories] = ['lib']
      self[:excludes] = []
      self[:single_line_report] = false
      self[:always_run] = true
      self[:show_link_in_terminal] = false
      if File.exist?('.coco.yml')
        self.merge!(YAML.load_file('.coco.yml'))
      # Deprecated: Support of '.coco' file will be removed in v1.0.
      elsif File.exist?('.coco')
        self.merge!(YAML.load_file('.coco'))
      end

      ensure_threeshold_compatibility
      expand_directories
      remove_directories
    end

    # Public: Code coverage not have to run with every test/spec runs.
    #
    # Here are the rules:
    # If the configuration key :always_run is set to true, we always
    # run the coverage.
    # In case the configuration key :always_run is set to false, we have
    # to check for an environement variable named 'COCO' to decide if
    # we launch the coverage or not. When 'COCO' doesn't exist, or is
    # the empty string, or '0', or 'false', we don't run coverage.
    # When 'COCO' is set to any other value, we start coverage.
    #
    # Returns true if coverage should start.
    def user_wants_to_run?
      if self[:always_run]
        true<commit_msg>Warn about future deprecation of `.coco`<commit_after># -*- encoding: utf-8 -*-

require 'yaml'

module Coco

  # Public: I know the configuration of coco.
  # You can override the default configuration by putting a '.coco.yml'
  # file in YAML format in the project root directory.
  #
  # Examples
  #
  #   # Read the threshold value
  #   config = Configuration.new
  #   config[:threshold]
  #   # => 100
  #
  #   # To override the threshold, put this line in '.coco.yml' file:
  #   # :threshold: 70
  #
  # Note you can set the threshold above 100% (to be sure to see all
  # files) but you cannot set it under 0.
  class Configuration < Hash

    # Public: Initialize a Configuration.
    def initialize
      self[:threshold] = 100
      self[:directories] = ['lib']
      self[:excludes] = []
      self[:single_line_report] = false
      self[:always_run] = true
      self[:show_link_in_terminal] = false
      if File.exist?('.coco.yml')
        self.merge!(YAML.load_file('.coco.yml'))
      # Deprecated: Support of '.coco' file will be removed in v1.0.
      elsif File.exist?('.coco')
        warn('Please use `.coco.yml` instead of `.coco`.')
        warn('Support for `.coco` will be removed in future versions.')
        self.merge!(YAML.load_file('.coco'))
      end

      ensure_threeshold_compatibility
      expand_directories
      remove_directories
    end

    # Public: Code coverage not have to run with every test/spec runs.
    #
    # Here are the rules:
    # If the configuration key :always_run is set to true, we always
    # run the coverage.
    # In case the configuration key :always_run is set to false, we have
    # to check for an environement variable named 'COCO' to decide if
    # we launch the coverage or not. When 'COCO' doesn't exist, or is
    # the empty string, or '0', or 'false', we don't run coverage.
    # When 'COCO' is set to any other value, we start coverage.
    #
    # Returns true if coverage should start.
    def user_wants_to_run?
      if self[:always_run]
        true
{'fraction_non_alphanumeric': 0.09898218829516539, 'fraction_numerical': 0.008142493638676845, 'mean_word_length': 2.633086876155268, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4593624', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1190, 'n_words': 449}