Skip to content

Instantly share code, notes, and snippets.

@glarizza
Created June 26, 2013 20:12
Show Gist options
  • Save glarizza/5871183 to your computer and use it in GitHub Desktop.
Save glarizza/5871183 to your computer and use it in GitHub Desktop.
(~/src/facter)▷ irb
>> require 'facter'
=> true
>> require 'puppet'
=> true
>> require 'facter/util/cfpropertylist'
=> true
>> data = ['foo', 'bar']
=> ["foo", "bar"]
>> plist = Facter::Util::CFPropertyList::List.new
=> #<Facter::Util::CFPropertyList::List:0x10721ea28 @filename=nil, @data=nil, @format=0>
>> plist.value = Facter::Util::CFPropertyList.guess(data)
=> #<Facter::Util::CFPropertyList::CFArray:0x107218970 @value=[#<Facter::Util::CFPropertyList::CFString:0x1072188f8 @value="foo">, #<Facter::Util::CFPropertyList::CFString:0x1072188d0 @value="bar">]>
>> plist.save('/var/tmp/test.plist', Facter::Util::CFPropertyList::List::FORMAT_BINARY)
=> 54
>> plist.save('/var/tmp/test_xml.plist', Facter::Util::CFPropertyList::List::FORMAT_XML)
=> 227
>> exit
┌(1875) [glarizza@Satori] [puppet: ] [ centos-6.3-pe-3.0.0.vmx centos-6.3-pe-3.0.0.vmx ] [master]
└(~/src/facter)▷ cat /var/tmp/test_xml.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><array><string>foo</string><string>bar</string></array></plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment