<commit_before>module Ctrlo
  class Esc
    extend Term::ANSIColor
  end

  class Template
    def initialize(object)
      @object = object
    end

    def self.parse(object)
      new(object).parse
    end

    def parse
      ERB.new(load, nil, "-").result(binding)
    end

    def load
      File.read(File.dirname(__FILE__) + object.template_file)
    end

    private
    attr_reader :object

    def half_horizontal_line
      "-" * (width / 2).floor
    end

    def horizontal_line
      "-" * width
    end

    def label(string = nil)
      Esc.blue + Esc.underline + string + Esc.reset
    end

    def member(string = nil)
      Esc.red + string + Esc.reset
    end

    def metadata(label, data)
      Esc.cyan + label.rjust(9) + Esc.reset + " " + data
    end

    def width
      terminal_size[0] || 80
    end

    def height
      terminal_size[1] || 25
    end

    def terminal_size
      @terminal_size ||= Hirb::Util.detect_terminal_size
    end
  end
end<commit_msg>Extract '#determine_terminal_size' from Hirb.<commit_after>module Ctrlo
  class Esc
    extend Term::ANSIColor
  end

  class Template
    def initialize(object)
      @object = object
    end

    def self.parse(object)
      new(object).parse
    end

    def parse
      ERB.new(load, nil, "-").result(binding)
    end

    def load
      File.read(File.dirname(__FILE__) + object.template_file)
    end

    private
    attr_reader :object

    def half_horizontal_line
      "-" * (width / 2).floor
    end

    def horizontal_line
      "-" * width
    end

    def label(string = nil)
      Esc.blue + Esc.underline + string + Esc.reset
    end

    def member(string = nil)
      Esc.red + string + Esc.reset
    end

    def metadata(label, data)
      Esc.cyan + label.rjust(9) + Esc.reset + " " + data
    end

    def width
      terminal_size[0]
    end

    def height
      terminal_size[1]
    end

    def terminal_size
      @terminal_size ||= if (ENV['COLUMNS'] =~ /^\d+$/) && (ENV['LINES'] =~ /^\d+$/)
        [ENV['COLUMNS'].to_i, ENV['LINES'].to_i]
      elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && command_exists?('tput')
        [`tput cols`.to_i, `tput lines`.to_i]
      elsif STDIN.tty? && command_exists?('stty')
        `stty size`.scan(/\d+/).map { |s| s.to_i }.reverse
      else
        [80, 25]
      end
    rescue
      [80, 25]
    end

  end
end
{'fraction_non_alphanumeric': 0.12103505843071787, 'fraction_numerical': 0.008347245409015025, 'mean_word_length': 2.0809768637532136, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3715168', 'n_tokens_mistral': 854, 'n_tokens_neox': 808, 'n_words': 193}