<commit_before>require "pry"
require "defile"
require "defile/backend_examples"

tmp_path = File.expand_path("tmp", Dir.pwd)

if File.exist?(tmp_path)
  raise "temporary path #{tmp_path} already exists, refusing to run tests"
else
  RSpec.configure do |config|
    config.after :suite do
      FileUtils.rm_rf(tmp_path)
    end
  end
end

Defile.store = Defile::Backend::FileSystem.new(File.expand_path("default_store", tmp_path))
Defile.cache = Defile::Backend::FileSystem.new(File.expand_path("default_cache", tmp_path))

class Defile::FileDouble
  def initialize(data)
    @io = StringIO.new(data)
  end<commit_msg>Use tmpdir instead of ./tmp<commit_after>require "pry"
require "defile"
require "defile/backend_examples"

tmp_path = Dir.mktmpdir

at_exit do
  FileUtils.remove_entry_secure(tmp_path)
end

Defile.store = Defile::Backend::FileSystem.new(File.expand_path("default_store", tmp_path))
Defile.cache = Defile::Backend::FileSystem.new(File.expand_path("default_cache", tmp_path))

class Defile::FileDouble
  def initialize(data)
    @io = StringIO.new(data)
  end
{'fraction_non_alphanumeric': 0.12186046511627907, 'fraction_numerical': 0.0, 'mean_word_length': 6.032679738562091, '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': '5907944', 'n_tokens_mistral': 376, 'n_tokens_neox': 377, 'n_words': 73}