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

module Coco

  # I format coverages information for console output.
  class ConsoleFormatter < Formatter

    # single_line_report - Boolean
    #
    # Returns percent covered and associated filenames as a String.
    def format(single_line_report = false)
      single_line_report ? single_line_message : @formatted_output.join("\n")
    end

    # Returns String.
    def link
      unless @formatted_output.empty?
        "See file://" +
          File.expand_path(File.join(Coco::HtmlDirectory.new.coverage_dir,
                                     'index.html'))
      end
    end

    # covered   - Hash
    # uncovered - Array
    def initialize(covered, uncovered)
      super
      @formatted_output = []
      compute_percentage
      add_percentage_to_uncovered
      @formatted_output.sort!
      @formatted_output.map! do |percentage, filename|
        text = ColoredString.new "#{percentage}% #{filename}"
        if percentage <= 50
          text.red
        elsif percentage == 100
          text.green
        else
          text.yellow
        end
      end
    end

    private<commit_msg>fix color<commit_after># -*- encoding: utf-8 -*-

module Coco

  # I format coverages information for console output.
  class ConsoleFormatter < Formatter

    # single_line_report - Boolean
    #
    # Returns percent covered and associated filenames as a String.
    def format(single_line_report = false)
      single_line_report ? single_line_message : @formatted_output.join("\n")
    end

    # Returns String.
    def link
      unless @formatted_output.empty?
        "See file://" +
          File.expand_path(File.join(Coco::HtmlDirectory.new.coverage_dir,
                                     'index.html'))
      end
    end

    # covered   - Hash
    # uncovered - Array
    def initialize(covered, uncovered)
      super
      @formatted_output = []
      compute_percentage
      add_percentage_to_uncovered
      @formatted_output.sort!
      @formatted_output.map! do |percentage, filename|
        text = ColoredString.new "#{percentage}% #{filename}"
        if percentage <= 50
          text.red
        elsif percentage >= threshold
          text.green
        else
          text.yellow
        end
      end
    end

    private
{'fraction_non_alphanumeric': 0.0823937554206418, 'fraction_numerical': 0.0039028620988725065, 'mean_word_length': 2.059681697612732, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5922796', 'n_tokens_mistral': 659, 'n_tokens_neox': 631, 'n_words': 158}