Issue #21530 has been updated by Brian Warsing.

This problem is strange, but there is maybe a better workaround. See...

https://github.com/dayglojesus/facter/commit/e2bd87944c107818eb6a43e4d3458f133a9efdb3

Here, I have inverted the conditional that determines whether or not to 
pretty-print the XML.
The XML#to_str method says it can handle a Hash of params, but there's no easy 
way for it to be passed in.
This is not a good fix, but you can see what happens when you swap the 
defaults. The fix for this begins a little deeper in the stack, but if you want 
the default to be formatted XML, then this simple enough.

It seems to me that the default *should* be properly formatted XML as Clay 
prescribes.

The only question is, will it break something else?

----------------------------------------
Bug #21530: cfpropertylist .to_plist method doesn't output Apple standard XML 
format
https://projects.puppetlabs.com/issues/21530#change-95703

* Author: Clay Caviness
* Status: Accepted
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* Keywords: 
* Branch: 
* Affected Facter version: 
----------------------------------------
The output when using FORMAT_XML isn't in Apple style, with tab indention, but 
is instead all on one line. While this is valid XML, it's not pretty. We 
generally like to write XML plists and not binary, as they're simpler to read 
without extra tools.

<pre>
$ ruby -r facter -r facter/util/plist -e "p = {'foo'=&gt;'bar', 
'baz'=&gt;[1,2,3]}.to_plist(); puts p"
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  &lt;key&gt;baz&lt;/key&gt;
  &lt;array&gt;
    &lt;integer&gt;1&lt;/integer&gt;
    &lt;integer&gt;2&lt;/integer&gt;
    &lt;integer&gt;3&lt;/integer&gt;
  &lt;/array&gt;
  &lt;key&gt;foo&lt;/key&gt;
  &lt;string&gt;bar&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;
$ facter --version
1.6.2
$ sudo pkgutil --forget com.reductivelabs.facter
Forgot package 'com.reductivelabs.facter' on '/'.
$ sudo installer -target / -pkg /Volumes/facter-1.7.1/facter-1.7.1.pkg
installer: Package name is facter-1.7.1
installer: Installing at base path /
installer: The install was successful.
$ ruby -r facter -r facter/util/cfpropertylist -e "p = {'foo'=&gt;'bar', 
'baz'=&gt;[1,2,3]}.to_plist({:plist_format=&gt;2}); puts p"
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist 
version="1.0"&gt;&lt;dict&gt;&lt;key&gt;baz&lt;/key&gt;&lt;array&gt;&lt;integer&gt;1&lt;/integer&gt;&lt;integer&gt;2&lt;/integer&gt;&lt;integer&gt;3&lt;/integer&gt;&lt;/array&gt;&lt;key&gt;foo&lt;/key&gt;&lt;string&gt;bar&lt;/string&gt;&lt;/dict&gt;&lt;/plist&gt;
$ facter --version
1.7.1
</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to