<commit_before>require 'tmpdir'

def run_in_dir(dir, *cmd)
  Bundler.with_clean_env do
    inject_test_env!
    Dir.chdir dir do
      Open3.popen2e(*cmd) do |_, out, waiter|
        status = waiter.value
        raise "#{cmd.join(' ')} failed with status #{status.exitstatus} output:\n#{out.read}" unless status.success?
      end
    end
  end
end

def amqp_url
  ENV['BOXES_AMQP_URL'] || 'amqp://boxes:boxes@localhost'
end

def tmp_media_root
  $tmp_media_root ||= Pathname.new(Dir.mktmpdir)
end

def media_root
  ENV['BOXES_MEDIA_ROOT'] || tmp_media_root.to_s
end
<commit_msg>added temp file cleanup to cucumber<commit_after>require 'tmpdir'

def run_in_dir(dir, *cmd)
  Bundler.with_clean_env do
    inject_test_env!
    Dir.chdir dir do
      Open3.popen2e(*cmd) do |_, out, waiter|
        status = waiter.value
        raise "#{cmd.join(' ')} failed with status #{status.exitstatus} output:\n#{out.read}" unless status.success?
      end
    end
  end
end

def amqp_url
  ENV['BOXES_AMQP_URL'] || 'amqp://boxes:boxes@localhost'
end

def tmp_media_root
  unless $tmp_media_root
    $tmp_media_root = Pathname.new(Dir.mktmpdir)
    puts "Created tmp media root #{$tmp_media_root}"

    at_exit do
      FileUtils.rm_rf $tmp_media_root
      puts "Deleted tmp media door #{$tmp_media_root}"
    end
  end

  $tmp_media_root
end

def media_root
  ENV['BOXES_MEDIA_ROOT'] || tmp_media_root.to_s
end

{'fraction_non_alphanumeric': 0.11269614835948645, 'fraction_numerical': 0.0028530670470756064, 'mean_word_length': 3.6766666666666667, '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': '2855438', 'n_tokens_mistral': 532, 'n_tokens_neox': 525, 'n_words': 116}