<commit_before>module TownCrier
  class AMQP
    attr_accessor :key, :config
    attr_writer :client, :exchange

    def initialize attributes = nil
      attributes ||= {}

      self.key    = attributes[:key]
      self.config = attributes.fetch(:config) do
        TownCrier.default_options[:amqp][:config]
      end
    end

    def publish payload
      exchange.publish payload, :content_type => 'application/json',
                                :persistent   => true,
                                :key          => key
    rescue => e
      raise PublishError.new('A publishing error occurred', e)
    end<commit_msg>Add a test mode to publishing so that our test queue picks it up.<commit_after>module TownCrier
  class AMQP
    attr_accessor :key, :config
    attr_writer :client, :exchange

    def initialize attributes = nil
      attributes ||= {}

      self.key    = attributes[:key]
      self.config = attributes.fetch(:config) do
        TownCrier.default_options[:amqp][:config]
      end
    end

    def publish payload, options = {}
      exchange.publish payload, :content_type => 'application/json',
                                :persistent   => true,
                                :key          => options[:test] ? "test.#{key}" : key
    rescue => e
      raise PublishError.new('A publishing error occurred', e)
    end
{'fraction_non_alphanumeric': 0.0959409594095941, 'fraction_numerical': 0.0, 'mean_word_length': 2.020044543429844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6400525', 'n_tokens_mistral': 364, 'n_tokens_neox': 354, 'n_words': 101}