Skip to content

Instantly share code, notes, and snippets.

View alanjrogers's full-sized avatar
💭
I may be slow to respond.

Alan Rogers alanjrogers

💭
I may be slow to respond.
  • Melbourne, Australia
View GitHub Profile
@alanjrogers
alanjrogers / AppleBinaryPropertyList.rb
Created October 16, 2010 02:38
Can't remember where I found this, but it works a treat.
require 'iconv'
module AppleBinaryPropertyList
MIME_TYPE = 'application/octet-stream' # Don't know what to use, so use a very generic type for now
CFData = Struct.new(:data) # For marking strings as binary data which will be decoded as a CFData object
# Convert a Ruby data structure into an OS X binary property list file. (.plist)
# Works as you'd expect. Integers are limited to 4 bytes, even though the format implies longer values can be written.