提交 d4091d3b 编写于 作者: J Jeremy Kemper

Properly set up libxml includes. Don't include LibXML in toplevel.

[#2084 state:resolved]
上级 e609d83f
# = XML Mini Libxml implementation require 'libxml'
# = XmlMini LibXML implementation
module ActiveSupport module ActiveSupport
module XmlMini_LibXML #:nodoc: module XmlMini_LibXML #:nodoc:
extend self extend self
...@@ -7,19 +9,19 @@ module XmlMini_LibXML #:nodoc: ...@@ -7,19 +9,19 @@ module XmlMini_LibXML #:nodoc:
# string:: # string::
# XML Document string to parse # XML Document string to parse
def parse(string) def parse(string)
XML.default_keep_blanks = false LibXML::XML.default_keep_blanks = false
if string.blank? if string.blank?
{} {}
else else
XML::Parser.string(string.strip).parse.to_hash LibXML::XML::Parser.string(string.strip).parse.to_hash
end end
end end
end end
end end
module XML module LibXML
module Conversions module Conversions
module Document module Document
def to_hash def to_hash
...@@ -37,7 +39,7 @@ module Node ...@@ -37,7 +39,7 @@ module Node
# Hash to merge the converted element into. # Hash to merge the converted element into.
def to_hash(hash={}) def to_hash(hash={})
if text? if text?
raise RuntimeError if content.length >= LIB_XML_LIMIT raise LibXML::XML::Error if content.length >= LIB_XML_LIMIT
hash[CONTENT_ROOT] = content hash[CONTENT_ROOT] = content
else else
sub_hash = insert_name_into_hash(hash, name) sub_hash = insert_name_into_hash(hash, name)
...@@ -127,5 +129,5 @@ def yaml? ...@@ -127,5 +129,5 @@ def yaml?
end end
end end
XML::Document.send(:include, XML::Conversions::Document) LibXML::XML::Document.send(:include, LibXML::Conversions::Document)
XML::Node.send(:include, XML::Conversions::Node) LibXML::XML::Node.send(:include, LibXML::Conversions::Node)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册