<commit_before>require 'qup/adapter/kestrel/destination'
class Qup::Adapter::Kestrel
  #
  # Public: A Topic for use in a publish-subscribe Messaging
  #
  # The topic delivers each Message that it is give to each and every Subscriber
  #
  class Topic < Destination
    include Qup::TopicAPI

    # Public: Creates a Publisher for the Topic
    #
    # Returns a new Publisher
    def publisher
      ::Qup::Publisher.new( self )
    end

    # Public: Create a subscriber for the Topic
    #
    # name - the String name of the subscriber
    #
    # Creating a subscriber creates a new Subscriber that will receive a copy of
    # every message that is published to the Topic.
    #
    # Subscribers are unique by name, two subscribers with the same name will
    # act as individual Consumers on a queue of their name.
    #
    # Returns a Subscriber
    def subscriber( name )
      ::Qup::Subscriber.new( self, subscriber_queue( name )  )
    end

    # Public: Return the number of Subscribers to this Topic
    #
    # Returns integer
    def subscriber_count
      c = 0
      puts @client.stats.inspect
      @client.stats['queues'].keys.each do |k|
        next if k =~ /errors$/
        c += 1 if k =~ /^#{@name}\+/
      end
      return c
    end

    # Internal: Publish a Message to all the Subscribers
    #
    # message - the Object to send to all subscribers
    #
    # Returns nothing
    def publish( message )
      @client.set( @name, message )
    end

    #######
    private
    #######
    #
    def subscriber_queue_name( sub_name )
      "#{@name}+#{sub_name}"
    end

    def subscriber_queue( sub_name )
      sname = subscriber_queue_name( sub_name )
      ::Qup::Adapter::Kestrel::Queue.new( @addr, sname )
    end
  end
end<commit_msg>3 hours of debugging, remember to use ruby -w<commit_after>require 'qup/adapter/kestrel/destination'
class Qup::Adapter::Kestrel
  #
  # Public: A Topic for use in a publish-subscribe Messaging
  #
  # The topic delivers each Message that it is give to each and every Subscriber
  #
  class Topic < Destination
    include Qup::TopicAPI

    # Public: Creates a Publisher for the Topic
    #
    # Returns a new Publisher
    def publisher
      ::Qup::Publisher.new( self )
    end

    # Public: Create a subscriber for the Topic
    #
    # name - the String name of the subscriber
    #
    # Creating a subscriber creates a new Subscriber that will receive a copy of
    # every message that is published to the Topic.
    #
    # Subscribers are unique by name, two subscribers with the same name will
    # act as individual Consumers on a queue of their name.
    #
    # Returns a Subscriber
    def subscriber( name )
      ::Qup::Subscriber.new( self, subscriber_queue( name )  )
    end

    # Public: Return the number of Subscribers to this Topic
    #
    # Returns integer
    def subscriber_count
      c = 0
      puts @client.stats.inspect
      @client.stats['queues'].keys.each do |k|
        next if k =~ /errors$/
        c += 1 if k =~ /^#{@name}\+/
      end
      return c
    end

    # Internal: Publish a Message to all the Subscribers
    #
    # message - the Object to send to all subscribers
    #
    # Returns nothing
    def publish( message )
      @client.set( @name, message )
    end

    #######
    private
    #######
    #
    def subscriber_queue_name( sub_name )
      "#{@name}+#{sub_name}"
    end

    def subscriber_queue( sub_name )
      sname = subscriber_queue_name( sub_name )
      ::Qup::Adapter::Kestrel::Queue.new( @address, sname )
    end
  end
end
{'fraction_non_alphanumeric': 0.08819425062796539, 'fraction_numerical': 0.0013954786491766676, 'mean_word_length': 2.4133333333333336, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6517974', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1070, 'n_words': 391}