<commit_before>module Chatterbox::ExceptionNotification
  class RailsExtracter
    def self.wrap(notification = {})
      new(notification).notice
    end

    def initialize(message = {})
      @message = message
    end

    def notice
      hsh = extract_rails_info(@message)
      hsh = extract_request_info(hsh)
      hsh
    end

    def rails_configuration
      Object.const_get("Rails") if Object.const_defined?("Rails")
    end

    def extract_rails_info(message)
      return message if rails_configuration.nil?
      message.merge({
        :rails_info => {
          :rails_env => rails_configuration.env,
          :rails_root => rails_configuration.root,
          :rails_version => rails_configuration.version
        }
      })
    end
    
    def extract_request_info(message)
      return message unless message.key?(:request)
      request = message.delete(:request)
      message.merge({<commit_msg>to_s for env and root, as these can be real objects and not just strings<commit_after>module Chatterbox::ExceptionNotification
  class RailsExtracter
    def self.wrap(notification = {})
      new(notification).notice
    end

    def initialize(message = {})
      @message = message
    end

    def notice
      hsh = extract_rails_info(@message)
      hsh = extract_request_info(hsh)
      hsh
    end

    def rails_configuration
      Object.const_get("Rails") if Object.const_defined?("Rails")
    end

    def extract_rails_info(message)
      return message if rails_configuration.nil?
      message.merge({
        :rails_info => {
          :rails_env => rails_configuration.env.to_s,
          :rails_root => rails_configuration.root.to_s,
          :rails_version => rails_configuration.version
        }
      })
    end
    
    def extract_request_info(message)
      return message unless message.key?(:request)
      request = message.delete(:request)
      message.merge({
{'fraction_non_alphanumeric': 0.0872974385781495, 'fraction_numerical': 0.0, 'mean_word_length': 2.702127659574468, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6268610', 'n_tokens_mistral': 560, 'n_tokens_neox': 533, 'n_words': 115}