<commit_before>require 'webrick'

# like WEBrick::HTTPServer, but listens on UNIX socket
class HTTPUNIXServer < WEBrick::HTTPServer
  def listen(address, port)
    socket = Socket.unix_server_socket(address)
    socket.autoclose = false
    server = UNIXServer.for_fd(socket.fileno)
    socket.close
    @listeners << server
  end

  # Workaround:
  # https://bugs.ruby-lang.org/issues/10956
  # Affecting Ruby 2.2
  # Fix for 2.2 is at https://github.com/ruby/ruby/commit/ab0a64e1
  # However, this doesn't work with 2.1. The following should work for both:
  def start(&block)
    @shutdown_pipe = IO.pipe
    shutdown_pipe = @shutdown_pipe
    super(&block)
  end
<commit_msg>Disable WEBrick logging in HTTPUNIXServer to reduce spec output noise<commit_after>require 'webrick'

# like WEBrick::HTTPServer, but listens on UNIX socket
class HTTPUNIXServer < WEBrick::HTTPServer
  def initialize(config = {})
    null_log = WEBrick::Log.new(IO::NULL, 7)

    super(config.merge(Logger: null_log, AccessLog: null_log))
  end

  def listen(address, port)
    socket = Socket.unix_server_socket(address)
    socket.autoclose = false
    server = UNIXServer.for_fd(socket.fileno)
    socket.close
    @listeners << server
  end

  # Workaround:
  # https://bugs.ruby-lang.org/issues/10956
  # Affecting Ruby 2.2
  # Fix for 2.2 is at https://github.com/ruby/ruby/commit/ab0a64e1
  # However, this doesn't work with 2.1. The following should work for both:
  def start(&block)
    @shutdown_pipe = IO.pipe
    shutdown_pipe = @shutdown_pipe
    super(&block)
  end

{'fraction_non_alphanumeric': 0.10384615384615385, 'fraction_numerical': 0.01987179487179487, 'mean_word_length': 3.74468085106383, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '6938147', 'n_tokens_mistral': 564, 'n_tokens_neox': 535, 'n_words': 131}