<commit_before># rubocop:disable Style/GlobalVars

require 'digest'
require 'mkmf'
require 'open-uri'

LIB_PG_QUERY_TAG = '10-1.0.4'.freeze
LIB_PG_QUERY_SHA256SUM = '88cc90296e5fcaaebd0b360c46698b7c5badddf86f120e249ef682a820d41338'.freeze

workdir = Dir.pwd
libdir = File.join(workdir, 'libpg_query-' + LIB_PG_QUERY_TAG)
gemdir = File.join(__dir__, '../..')
libfile = libdir + '/libpg_query.a'
filename = File.join(workdir, 'libpg_query-' + LIB_PG_QUERY_TAG + '.tar.gz')

unless File.exist?(filename)
  File.open(filename, 'wb') do |target_file|
    URI.open('https://codeload.github.com/lfittl/libpg_query/tar.gz/' + LIB_PG_QUERY_TAG, 'rb') do |read_file|
      target_file.write(read_file.read)
    end
  end

  checksum = Digest::SHA256.hexdigest(File.read(filename))

  if checksum != LIB_PG_QUERY_SHA256SUM
    raise "SHA256 of #{filename} does not match: got #{checksum}, expected #{expected_sha256}"
  end
end

unless Dir.exist?(libdir)
  system("tar -xzf #{filename}") || raise('ERROR')
end

unless Dir.exist?(libfile)
  # Build libpg_query (and parts of PostgreSQL)
  system(format("cd %s; %s build", libdir, ENV['MAKE'] || (RUBY_PLATFORM =~ /bsd/ ? 'gmake' : 'make')))
end

# Copy test files (this intentionally overwrites existing files!)
system("cp #{libdir}/testdata/* #{gemdir}/spec/files/")

$objs = ['pg_query_ruby.o']
<commit_msg>fix undefined local variable or method `expected_sha256'<commit_after># rubocop:disable Style/GlobalVars

require 'digest'
require 'mkmf'
require 'open-uri'

LIB_PG_QUERY_TAG = '10-1.0.4'.freeze
LIB_PG_QUERY_SHA256SUM = '88cc90296e5fcaaebd0b360c46698b7c5badddf86f120e249ef682a820d41338'.freeze

workdir = Dir.pwd
libdir = File.join(workdir, 'libpg_query-' + LIB_PG_QUERY_TAG)
gemdir = File.join(__dir__, '../..')
libfile = libdir + '/libpg_query.a'
filename = File.join(workdir, 'libpg_query-' + LIB_PG_QUERY_TAG + '.tar.gz')

unless File.exist?(filename)
  File.open(filename, 'wb') do |target_file|
    URI.open('https://codeload.github.com/lfittl/libpg_query/tar.gz/' + LIB_PG_QUERY_TAG, 'rb') do |read_file|
      target_file.write(read_file.read)
    end
  end

  checksum = Digest::SHA256.hexdigest(File.read(filename))

  if checksum != LIB_PG_QUERY_SHA256SUM
    raise "SHA256 of #{filename} does not match: got #{checksum}, expected #{LIB_PG_QUERY_SHA256SUM}"
  end
end

unless Dir.exist?(libdir)
  system("tar -xzf #{filename}") || raise('ERROR')
end

unless Dir.exist?(libfile)
  # Build libpg_query (and parts of PostgreSQL)
  system(format("cd %s; %s build", libdir, ENV['MAKE'] || (RUBY_PLATFORM =~ /bsd/ ? 'gmake' : 'make')))
end

# Copy test files (this intentionally overwrites existing files!)
system("cp #{libdir}/testdata/* #{gemdir}/spec/files/")

$objs = ['pg_query_ruby.o']

{'fraction_non_alphanumeric': 0.15306122448979592, 'fraction_numerical': 0.04336734693877551, 'mean_word_length': 5.252847380410023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6475690', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1065, 'n_words': 206}