Skip to content

Commit

Permalink
Make bundles_all if there are no bundles.
Browse files Browse the repository at this point in the history
  • Loading branch information
yyamano committed Nov 30, 2011
1 parent ef2de19 commit 133075e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/www/delicious.rb
Expand Up @@ -622,11 +622,13 @@ def wait_before_new_request
def parse_and_validate_response(body, options = {})
dom = REXML::Document.new(body)

if (value = options[:root_name]) && dom.root.name != value
raise ResponseError, "Invalid response, root node is not `#{value}`"
end
if (value = options[:root_text]) && dom.root.text != value
raise ResponseError, value
if (!dom.root.nil?)
if (value = options[:root_name]) && dom.root.name != value
raise ResponseError, "Invalid response, root node is not `#{value}`"
end
if (value = options[:root_text]) && dom.root.text != value
raise ResponseError, value
end
end

return dom
Expand Down Expand Up @@ -658,6 +660,9 @@ def parse_update_response(body)
# and returns an array of <tt>WWW::Delicious::Bundle</tt>.
def parse_bundle_collection(body)
dom = parse_and_validate_response(body, :root_name => 'bundles')
if (dom.root.nil?)
return []
end
dom.root.elements.collect('bundle') { |xml| Bundle.from_rexml(xml) }
end

Expand Down

0 comments on commit 133075e

Please sign in to comment.