<commit_before>require File.dirname(__FILE__) + "/ext/enumerable.rb"
require "bunny"
require 'timeout'

module QueueMap
  BUNNY_MUTEX = Mutex.new
  extend self
  attr_accessor :mode
  attr_accessor :consumer_base_path
  attr_accessor :consumer_path

  DEFAULT_ON_TIMEOUT = lambda { |r| nil }

  def unique_name
    @unique_name ||= "#{`hostname`.chomp}-#{Process.pid}-#{Time.now.usec}"
  end

  def consumer_path
    @consumer_path ||= Hash.new do |hash, key|
      File.join(consumer_base_path, "#{key}_consumer.rb")
    end
  end

  def response_queue_name(name)
    @inc ||= 0
    "#{name}_response_#{unique_name}_#{@inc += 1}"
  end

  def map(collection, name, options = {})
    return queue_map_internal(collection, name) if mode == :test
<commit_msg>autoload Consumer<commit_after>require File.dirname(__FILE__) + "/ext/enumerable.rb"
require "bunny"
require 'timeout'

module QueueMap
  autoload :Consumer, File.dirname(__FILE__) + "/queue_map/consumer"
  BUNNY_MUTEX = Mutex.new
  extend self
  attr_accessor :mode
  attr_accessor :consumer_base_path
  attr_accessor :consumer_path

  DEFAULT_ON_TIMEOUT = lambda { |r| nil }

  def unique_name
    @unique_name ||= "#{`hostname`.chomp}-#{Process.pid}-#{Time.now.usec}"
  end

  def consumer_path
    @consumer_path ||= Hash.new do |hash, key|
      File.join(consumer_base_path, "#{key}_consumer.rb")
    end
  end

  def response_queue_name(name)
    @inc ||= 0
    "#{name}_response_#{unique_name}_#{@inc += 1}"
  end

  def map(collection, name, options = {})
    return queue_map_internal(collection, name) if mode == :test

{'fraction_non_alphanumeric': 0.1323251417769376, 'fraction_numerical': 0.002520478890989288, 'mean_word_length': 4.293333333333333, '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': '3660575', 'n_tokens_mistral': 580, 'n_tokens_neox': 565, 'n_words': 117}