<commit_before>require 'rubygems'
require 'spec'

require "ffi"
include FFI

module TestLibrary
  FIXTURE_DIR = File.expand_path("../fixtures", __FILE__)
  PATH = File.join(FIXTURE_DIR, "build/libtest/libtest.#{FFI::Platform::LIBSUFFIX}")
  
  def self.need_to_compile_fixtures?
    !File.exist?(PATH) or Dir.glob(File.join(FIXTURE_DIR, "*")).any? { |f| File.mtime(f) > File.mtime(PATH) }
  end
  
  if need_to_compile_fixtures?
    puts "[!] Compiling Ruby-FFI fixtures"
    unless system("make -f #{File.join(FIXTURE_DIR, 'GNUmakefile')}")
      raise "Failed to compile Ruby-FFI fixtures"
    end
  end
end

module LibTest
  extend FFI::Library
  ffi_lib TestLibrary::PATH
end
<commit_msg>Make sure the Ruby-FFI fixtures are compiled regardless of the current working directory.<commit_after>require 'rubygems'
require 'spec'

require "ffi"
include FFI

module TestLibrary
  FIXTURE_DIR = File.expand_path("../fixtures", __FILE__)
  PATH = File.join(FIXTURE_DIR, "build/libtest/libtest.#{FFI::Platform::LIBSUFFIX}")
  
  def self.need_to_compile_fixtures?
    !File.exist?(PATH) or Dir.glob(File.join(FIXTURE_DIR, "*")).any? { |f| File.mtime(f) > File.mtime(PATH) }
  end
  
  if need_to_compile_fixtures?
    puts "[!] Compiling Ruby-FFI fixtures"
    Dir.chdir(File.dirname(FIXTURE_DIR)) do
      unless system("make -f fixtures/GNUmakefile")
        raise "Failed to compile Ruby-FFI fixtures"
      end
    end
  end
end

module LibTest
  extend FFI::Library
  ffi_lib TestLibrary::PATH
end

{'fraction_non_alphanumeric': 0.12550066755674233, 'fraction_numerical': 0.0, 'mean_word_length': 4.296819787985866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6770027', 'n_tokens_mistral': 550, 'n_tokens_neox': 550, 'n_words': 120}