<commit_before>module CfScript
  class Output::Buffer
    attr_reader :raw

    ANSI_ESCAPE_SEQUENCE_REGEXP = /\e\[(\d+)(;\d+)*m/

    def initialize(buffer = nil)
      @raw = buffer
    end

    def content
      @clean_content ||= sanitize
    end

    def lines
      @clean_lines ||= sanitize_lines
    end

    def last_line
      lines.last
    end

    def [](arg)
      content[arg]
    end

    def each_line(&block)
      content.each_line(&block)
    end

    def from(pattern)
      lines_from(pattern).join("\n")
    end

    def lines_from(pattern)
      index = lines.find_index { |line| line =~ /#{pattern}/ }
      index ? lines[index..-1] : []
    end

    def match(regexp)
      content.match(regexp)
    end

    def matches?(regexp)
      content =~ regexp ? true : false
    end

    def contains?(text)
      matches? /#{text}/
    end
<commit_msg>Exclude empty lines in Output::Buffer#last_line<commit_after>module CfScript
  class Output::Buffer
    attr_reader :raw

    ANSI_ESCAPE_SEQUENCE_REGEXP = /\e\[(\d+)(;\d+)*m/

    def initialize(buffer = nil)
      @raw = buffer
    end

    def content
      @clean_content ||= sanitize
    end

    def lines
      @clean_lines ||= sanitize_lines
    end

    def last_line
      lines.reject(&:empty?).last
    end

    def [](arg)
      content[arg]
    end

    def each_line(&block)
      content.each_line(&block)
    end

    def from(pattern)
      lines_from(pattern).join("\n")
    end

    def lines_from(pattern)
      index = lines.find_index { |line| line =~ /#{pattern}/ }
      index ? lines[index..-1] : []
    end

    def match(regexp)
      content.match(regexp)
    end

    def matches?(regexp)
      content =~ regexp ? true : false
    end

    def contains?(text)
      matches? /#{text}/
    end

{'fraction_non_alphanumeric': 0.12075681691708402, 'fraction_numerical': 0.0011129660545353367, 'mean_word_length': 2.1543859649122807, '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': '4798669', 'n_tokens_mistral': 620, 'n_tokens_neox': 598, 'n_words': 136}