<commit_before>module Signore class Wrapper

  NBSP = ' '

  def initialize text, meta
    @lines = text.split "\n"
    @lines.last << " [#{meta.tr ' ', NBSP}]" if meta
    @meta = meta ? (meta.size + 2) : nil
  end

  def display
    wrap
    right_align_meta
    @lines.join("\n").tr NBSP, ' '
  end

  private

  def right_align_meta
    return unless @meta
    @lines.map! { |l| l.split "\n" }.flatten!
    lenghts = @lines.map(&:size)
    if lenghts.size > 1 and lenghts.last == lenghts.max and lenghts.count(lenghts.last) == 1 and lenghts.last != @meta
      last = @lines.pop
      @lines << last[0...-@meta-1]
      @lines << last[-@meta..-1]
    end
    width = @lines.map(&:size).max
    @lines.last.insert -@meta - 1, ' ' * (width - @lines.last.size)
  end

  def wrap
    @lines.map! do |line|
      wrap_line line, line == @lines.last
    end
  end

  def wrap_line line, is_last
    best_wrap = line.gsub /(.{1,80})( |$\n?)/, "\\1\n"
    79.downto 1 do |size|
      new_wrap = line.gsub /(.{1,#{size}})( |$\n?)/, "\\1\n"
      break if new_wrap.count("\n") > best_wrap.count("\n")
      lengths = new_wrap.split("\n").map(&:size)<commit_msg>get rid of Ruby warnings<commit_after>module Signore class Wrapper

  NBSP = ' '

  def initialize text, meta
    @lines = text.split "\n"
    @lines.last << " [#{meta.tr ' ', NBSP}]" if meta
    @meta = meta ? (meta.size + 2) : nil
  end

  def display
    wrap
    right_align_meta
    @lines.join("\n").tr NBSP, ' '
  end

  private

  def right_align_meta
    return unless @meta
    @lines.map! { |l| l.split "\n" }.flatten!
    lenghts = @lines.map(&:size)
    if lenghts.size > 1 and lenghts.last == lenghts.max and lenghts.count(lenghts.last) == 1 and lenghts.last != @meta
      last = @lines.pop
      @lines << last[0...-@meta-1]
      @lines << last[-@meta..-1]
    end
    width = @lines.map(&:size).max
    @lines.last.insert(-@meta - 1, ' ' * (width - @lines.last.size))
  end

  def wrap
    @lines.map! do |line|
      wrap_line line, line == @lines.last
    end
  end

  def wrap_line line, is_last
    best_wrap = line.gsub(/(.{1,80})( |$\n?)/, "\\1\n")
    79.downto 1 do |size|
      new_wrap = line.gsub(/(.{1,#{size}})( |$\n?)/, "\\1\n")
      break if new_wrap.count("\n") > best_wrap.count("\n")
      lengths = new_wrap.split("\n").map(&:size)
{'fraction_non_alphanumeric': 0.1901893287435456, 'fraction_numerical': 0.013769363166953529, 'mean_word_length': 2.3991228070175437, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, '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': '199799', 'n_tokens_mistral': 957, 'n_tokens_neox': 901, 'n_words': 210}