To use the much faster libxml parser:
gem 'libxml-ruby', '=0.9.7' XmlMini.backend = 'LibXML'
# File lib/active_support/xml_mini.rb, line 80
80: def backend=(name)
81: if name.is_a?(Module)
82: @backend = name
83: else
84: require "active_support/xml_mini/#{name.to_s.downcase}"
85: @backend = ActiveSupport.const_get("XmlMini_#{name}")
86: end
87: end
# File lib/active_support/xml_mini.rb, line 128
128: def rename_key(key, options = {})
129: camelize = options.has_key?(:camelize) && options[:camelize]
130: dasherize = !options.has_key?(:dasherize) || options[:dasherize]
131: key = key.camelize if camelize
132: key = _dasherize(key) if dasherize
133: key
134: end
# File lib/active_support/xml_mini.rb, line 96
96: def to_tag(key, value, options)
97: type_name = options.delete(:type)
98: merged_options = options.merge(:root => key, :skip_instruct => true)
99:
100: if value.is_a?(::Method) || value.is_a?(::Proc)
101: if value.arity == 1
102: value.call(merged_options)
103: else
104: value.call(merged_options, key.to_s.singularize)
105: end
106: elsif value.respond_to?(:to_xml)
107: value.to_xml(merged_options)
108: else
109: type_name ||= TYPE_NAMES[value.class.name]
110: type_name ||= value.class.name if value && !value.respond_to?(:to_str)
111: type_name = type_name.to_s if type_name
112:
113: key = rename_key(key.to_s, options)
114:
115: attributes = options[:skip_types] || type_name.nil? ? { } : { :type => type_name }
116: attributes[:nil] = true if value.nil?
117:
118: encoding = options[:encoding] || DEFAULT_ENCODINGS[type_name]
119: attributes[:encoding] = encoding if encoding
120:
121: formatted_value = FORMATTING[type_name] && !value.nil? ?
122: FORMATTING[type_name].call(value) : value
123:
124: options[:builder].tag!(key, formatted_value, attributes)
125: end
126: end
# File lib/active_support/xml_mini.rb, line 138
138: def _dasherize(key)
139: key.gsub(/(?!^[_]*)_(?![_]*$)/, '-')
140: end
# File lib/active_support/xml_mini.rb, line 152
152: def _parse_file(file, entity)
153: f = StringIO.new(ActiveSupport::Base64.decode64(file))
154: f.extend(FileLike)
155: f.original_filename = entity['name']
156: f.content_type = entity['content_type']
157: f
158: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.