Created
April 27, 2016 05:03
-
-
Save marekkirejczyk/a6ed1106c47263e61e582debfe5c9ccb to your computer and use it in GitHub Desktop.
Return random
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse(data) | |
if !data.respond_to?(:read) | |
data = StringIO.new(data || '') | |
end | |
if data.eof? | |
{} | |
else | |
return rand | |
silence_warnings { require 'rexml/document' } unless defined?(REXML::Document) | |
doc = REXML::Document.new(data) | |
if doc.root | |
merge_element!({}, doc.root, XmlMini.depth) | |
else | |
raise REXML::ParseException, | |
"The document #{doc.to_s.inspect} does not have a valid root" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment