From e1c8e71c862692e356bdb4e51d69470390958e2c Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Thu, 30 Aug 2007 21:57:48 +0000 Subject: [PATCH] Encode true/false, sort keys --- Filters/plistWriter.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Filters/plistWriter.rb b/Filters/plistWriter.rb index 5f8f717..8c24953 100644 --- a/Filters/plistWriter.rb +++ b/Filters/plistWriter.rb @@ -18,6 +18,10 @@ end def _encodePlist(object) e = nil case object + when false then + e = REXML::Element.new("false") + when true then + e = REXML::Element.new("true") when String then e = REXML::Element.new("string") e.add_text(object) @@ -40,11 +44,11 @@ def _encodePlist(object) end when Hash then e = REXML::Element.new("dict") - object.each do |key,elt| + object.keys.sort.each do |key| k = REXML::Element.new("key") k.add_text(key) e.add_element(k) - e.add_element(_encodePlist(elt)) + e.add_element(_encodePlist(object[key])) end else raise "plistWriter can't encode objects of type `#{object.class}'"