<commit_before>require 'active_support'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/string/starts_ends_with'
require 'active_support/core_ext/string/inflections.rb'
require 'active_support/core_ext/hash/reverse_merge.rb'

require 'hooks/inheritable_attribute'


require 'roxml/definition'
require 'roxml/nokogiri_extensions'
require 'roxml/xml/references'

module ROXML
  VERSION = '3.1.5'

  def self.included(base)
    base.class_eval do
      extend  ClassMethods::Accessors,
              ClassMethods::Declarations,
              ClassMethods::Operations
      include InstanceMethods

      attr_accessor :roxml_references
      
      extend Hooks::InheritableAttribute
      inheritable_attr :roxml_attrs
      self.roxml_attrs = []
    end
  end

  module InstanceMethods # :nodoc:
    # Returns an XML object representing this object
    def to_xml(params={})
      params.reverse_merge!(:name => self.class.tag_name)
      
      Nokogiri::XML::Node.new(params[:name].to_s, Nokogiri::XML::Document.new).tap do |root|
        refs = self.class.roxml_attrs.map {|attr| attr.to_ref(self) } # FIXME: refactor to_ref.
        
        refs.each do |ref|
          value = public_send(ref.accessor) # DISCUSS: eventually move back to Ref.<commit_msg>fixed require bug.<commit_after>require 'active_support'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/string/starts_ends_with'
require 'active_support/core_ext/string/inflections.rb'
require 'active_support/core_ext/hash/reverse_merge.rb'

require 'hooks/inheritable_attribute'


require 'roxml/definition'
require 'roxml/nokogiri_extensions'
require 'roxml/references'

module ROXML
  VERSION = '3.1.5'

  def self.included(base)
    base.class_eval do
      extend  ClassMethods::Accessors,
              ClassMethods::Declarations,
              ClassMethods::Operations
      include InstanceMethods

      attr_accessor :roxml_references
      
      extend Hooks::InheritableAttribute
      inheritable_attr :roxml_attrs
      self.roxml_attrs = []
    end
  end

  module InstanceMethods # :nodoc:
    # Returns an XML object representing this object
    def to_xml(params={})
      params.reverse_merge!(:name => self.class.tag_name)
      
      Nokogiri::XML::Node.new(params[:name].to_s, Nokogiri::XML::Document.new).tap do |root|
        refs = self.class.roxml_attrs.map {|attr| attr.to_ref(self) } # FIXME: refactor to_ref.
        
        refs.each do |ref|
          value = public_send(ref.accessor) # DISCUSS: eventually move back to Ref.
{'fraction_non_alphanumeric': 0.09759704251386321, 'fraction_numerical': 0.0022181146025878, 'mean_word_length': 3.673575129533679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 17}, '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': '2699707', 'n_tokens_mistral': 860, 'n_tokens_neox': 853, 'n_words': 159}