From 133075e2b4c41424a6433cc0d9f642344cfeeac7 Mon Sep 17 00:00:00 2001 From: Yuji Yamano Date: Wed, 30 Nov 2011 12:39:56 -0800 Subject: [PATCH] Make bundles_all if there are no bundles. --- lib/www/delicious.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/www/delicious.rb b/lib/www/delicious.rb index dd286cb..f780655 100644 --- a/lib/www/delicious.rb +++ b/lib/www/delicious.rb @@ -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 @@ -658,6 +660,9 @@ def parse_update_response(body) # and returns an array of WWW::Delicious::Bundle. 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