<commit_before>require 'nokogiri'

module Punchblock
  module Protocol
    module Ozone
      class Message < Nokogiri::XML::Node
        BASE_OZONE_NAMESPACE = 'urn:xmpp:ozone'
        OZONE_VERSION        = '1'
        BASE_NAMESPACE_MESSAGES = %w[answer hangup]

        # Parent object that created this object, if applicable
        attr_accessor :parent, :headers

        ##
        # Create a new Ozone Message object.
        #
        # @param [Symbol, Required] Component for this new message
        # @param [Nokogiri::XML::Document, Optional] Existing XML document to which this message should be added
        #
        # @return [Ozone::Message] New Ozone Message object
        def self.new(klass, command = nil, parent = nil)
          # Ugly hack: we have to pass in the class name because
          # self.class returns "Class" right now
          name = klass.to_s.downcase
          element = command.nil? ? name : command
          obj = super element, Nokogiri::XML::Document.new
          scope = BASE_NAMESPACE_MESSAGES.include?(name) ? nil : name
          xmlns = [BASE_OZONE_NAMESPACE, scope, OZONE_VERSION].compact.join(':')
          obj.set_attribute 'xmlns', xmlns
          obj.parent = parent
          obj
        end

        def self.parse(xml)
          msg = xml.children.first<commit_msg>Headers are not an attribute of every message<commit_after>require 'nokogiri'

module Punchblock
  module Protocol
    module Ozone
      class Message < Nokogiri::XML::Node
        BASE_OZONE_NAMESPACE = 'urn:xmpp:ozone'
        OZONE_VERSION        = '1'
        BASE_NAMESPACE_MESSAGES = %w[answer hangup]

        # Parent object that created this object, if applicable
        attr_accessor :parent

        ##
        # Create a new Ozone Message object.
        #
        # @param [Symbol, Required] Component for this new message
        # @param [Nokogiri::XML::Document, Optional] Existing XML document to which this message should be added
        #
        # @return [Ozone::Message] New Ozone Message object
        def self.new(klass, command = nil, parent = nil)
          # Ugly hack: we have to pass in the class name because
          # self.class returns "Class" right now
          name = klass.to_s.downcase
          element = command.nil? ? name : command
          obj = super element, Nokogiri::XML::Document.new
          scope = BASE_NAMESPACE_MESSAGES.include?(name) ? nil : name
          xmlns = [BASE_OZONE_NAMESPACE, scope, OZONE_VERSION].compact.join(':')
          obj.set_attribute 'xmlns', xmlns
          obj.parent = parent
          obj
        end

        def self.parse(xml)
          msg = xml.children.first
{'fraction_non_alphanumeric': 0.08283582089552238, 'fraction_numerical': 0.0007462686567164179, 'mean_word_length': 2.2655298416565164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '4916588', 'n_tokens_mistral': 771, 'n_tokens_neox': 766, 'n_words': 231}