<commit_before>module Msgr

  class Railtie < ::Rails::Railtie
    config.msgr = ActiveSupport::OrderedOptions.new
    config.autoload_paths << File.expand_path("#{Rails.root}/app/consumers") if File.exist?("#{Rails.root}/app/consumers")

    initializer 'msgr.logger' do |app|
      app.config.msgr.logger ||= Rails.logger
    end

    initializer 'msgr.rabbitmq_config' do
      config.msgr.rabbitmq_config ||= Rails.root.join *%w(config rabbitmq.yml)
    end

    # Start msgr
    initializer 'msgr.start' do
      config.after_initialize do |app|
        Msgr.logger = app.config.msgr.logger

        self.class.load app.config.msgr
      end
    end

    class << self
      def load(rails_config)
        cfg = parse_config load_config rails_config.rabbitmq_config.to_s
        return unless cfg # no config given -> does not load Msgr

        Msgr.config = cfg
        Msgr.client.connect
      end

      def parse_config(cfg)
        unless cfg.is_a? Hash
          Rails.logger.wanr '[Msgr] Could not load rabbitmq config: Config must be a Hash'
          return nil
        end

        unless cfg[Rails.env].is_a?(Hash)
          raise ArgumentError, "Could not load rabbitmq config for environment \"#{Rails.env}\": is not a Hash"<commit_msg>Do what I wanted to do in last release<commit_after>module Msgr

  class Railtie < ::Rails::Railtie
    config.msgr = ActiveSupport::OrderedOptions.new
    config.autoload_paths << File.expand_path("#{Rails.root}/app/consumers") if File.exist?("#{Rails.root}/app/consumers")

    initializer 'msgr.logger' do |app|
      app.config.msgr.logger ||= Rails.logger
    end

    initializer 'msgr.rabbitmq_config' do
      config.msgr.rabbitmq_config ||= Rails.root.join *%w(config rabbitmq.yml)
    end

    # Start msgr
    initializer 'msgr.start' do
      config.after_initialize do |app|
        Msgr.logger = app.config.msgr.logger

        self.class.load app.config.msgr
      end
    end

    class << self
      def load(rails_config)
        cfg = parse_config load_config rails_config.rabbitmq_config.to_s
        return unless cfg # no config given -> does not load Msgr

        Msgr.config = cfg
        Msgr.client.connect
      end

      def parse_config(cfg)
        unless cfg.is_a? Hash
          Rails.logger.warn '[Msgr] Could not load rabbitmq config: Config must be a Hash'
          return nil
        end

        unless cfg[Rails.env].is_a?(Hash)
          Rails.logger.warn "Could not load rabbitmq config for environment \"#{Rails.env}\": is not a Hash"
          return nil
{'fraction_non_alphanumeric': 0.0990215264187867, 'fraction_numerical': 0.0, 'mean_word_length': 2.5401662049861495, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 5, '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': '1635450', 'n_tokens_mistral': 834, 'n_tokens_neox': 791, 'n_words': 204}