<commit_before>require 'set'
require 'yaml'

class Channel
  attr_reader :name, :logger, :subscribers

  def initialize(name:, logger:, subscribers:)
    @name = name
    @logger = logger
    @subscribers = Set.new(subscribers)
  end

  def add_subscriber(sub)
    subscribers << sub
  end

  def publish(message)
    subscribers.each{ |s| s.puts(message) }
  end

  def to_yaml
    subs = {}
    subscribers.each{ |sub| subs[sub.id.to_s] = sub.sender.to_s }

    {<commit_msg>Ref #45 - Forgot to have the logger actually log.<commit_after>require 'set'
require 'yaml'

class Channel
  attr_reader :name, :logger, :subscribers

  def initialize(name:, logger:, subscribers:)
    @name = name
    @logger = logger
    @subscribers = Set.new(subscribers)
  end

  def add_subscriber(sub)
    subscribers << sub
  end

  def publish(message)
    subscribers.each{ |s| s.puts(message) }
    logger.puts(message)
  end

  def to_yaml
    subs = {}
    subscribers.each{ |sub| subs[sub.id.to_s] = sub.sender.to_s }

    {
{'fraction_non_alphanumeric': 0.12019704433497537, 'fraction_numerical': 0.0019704433497536944, 'mean_word_length': 3.26890756302521, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2033120', 'n_tokens_mistral': 382, 'n_tokens_neox': 366, 'n_words': 87}