summaryrefslogtreecommitdiffstats
path: root/genome-bootstrap
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2008-07-11 14:27:05 -0400
committerBrenton Leanhardt <bleanhar@redhat.com>2008-07-11 15:02:18 -0400
commit3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3 (patch)
tree6b44eca9eeae273c0d1c0ba82f9f537cf150ffa0 /genome-bootstrap
parent53de95c9cb0d5c48341bb9c6124f4d640cd000d5 (diff)
downloadtools-3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3.tar.gz
tools-3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3.tar.xz
tools-3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3.zip
Minor bug fix for genome-bootstrap discovered by the django-example
The django-example only has one class. A String was getting returned where an Array was assumed. Yay for no unit tests for this. On a side note, the django-example was useful for uncovering a few corner cases with how we use Restr. The problem with Restr happens whenever 1 of something was returned. While it's nice enough wrap things in an Array if multiple items are returned, since Restr's XmlSimple instance is not setting 'forcearray => true' we have to wrap the call. It would probably be a good idea to ask the Restr maintainer about the 'forcearray' parameter.
Diffstat (limited to 'genome-bootstrap')
-rw-r--r--genome-bootstrap/extra/genome-bootstrap.spec2
-rw-r--r--genome-bootstrap/lib/genome-bootstrap/core.rb13
2 files changed, 8 insertions, 7 deletions
diff --git a/genome-bootstrap/extra/genome-bootstrap.spec b/genome-bootstrap/extra/genome-bootstrap.spec
index cf00c5b..86c6ae6 100644
--- a/genome-bootstrap/extra/genome-bootstrap.spec
+++ b/genome-bootstrap/extra/genome-bootstrap.spec
@@ -7,7 +7,7 @@ Summary: Tool for provisioning virtual machines
Name: rubygem-%{gemname}
Version: 1.0.0
-Release: 5%{?dist}
+Release: 6%{?dist}
Group: Development/Languages
License: Ruby License/GPL
Source0: %{gemname}-%{version}.gem
diff --git a/genome-bootstrap/lib/genome-bootstrap/core.rb b/genome-bootstrap/lib/genome-bootstrap/core.rb
index 28b7e61..8991753 100644
--- a/genome-bootstrap/lib/genome-bootstrap/core.rb
+++ b/genome-bootstrap/lib/genome-bootstrap/core.rb
@@ -136,17 +136,18 @@ module GenomeBootstrap
return status.nil? ? nil : status[0]
end
- # This is a workaround for a Restr "feature". If only one element it is
- # returned as a Hash instead of an Array. The way we use Restr assumes that it
- # will always return an Array.
+ # This is a workaround for a Restr "feature". Restr does not set
+ # 'forcearray => true' for it's XmlSimple instance. This means exactly
+ # what you would think. We always want to work with arrays since puppet's
+ # external nodes cares what data structures are used.
def restr_get(url, xml_node=nil)
data = xml_node ? Restr.get(url)[xml_node] : Restr.get(url)
return case data
- when Hash
- Array.new << data
- when Array
+ when nil, Array
data
+ else
+ Array.new << data
end
end
end