<commit_before>require "rubygems/package"

module Metacrunch
  class TarWriter < FileWriter

    def write(data, options = {})
      raise ArgumentError, "Missing option 'filename'" if options[:filename].blank?

      io.add_file_simple(options[:filename], 0644, data.bytesize) do |_io|
        if block_given?
          yield(_io)
        else
          _io.write(data)
        end
      end
    end

  private

    def io
      @io ||=  Gem::Package::TarWriter.new(super)
    end

  end
end
<commit_msg>Fix io in tar writer subclass.<commit_after>require "rubygems/package"

module Metacrunch
  class TarWriter < FileWriter

    def write(data, options = {})
      raise ArgumentError, "Missing option 'filename'" if options[:filename].blank?

      io.add_file_simple(options[:filename], 0644, data.bytesize) do |_io|
        if block_given?
          yield(_io)
        else
          _io.write(data)
        end
      end
    end

  private

    def io
      @io     ||= super
      @tar_io ||= Gem::Package::TarWriter.new(@io)
    end

  end
end

{'fraction_non_alphanumeric': 0.10266159695817491, 'fraction_numerical': 0.0076045627376425855, 'mean_word_length': 2.407766990291262, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7459317', 'n_tokens_mistral': 346, 'n_tokens_neox': 329, 'n_words': 83}