Method: Jamf::Utility#parse_plist
- Defined in:
- lib/jamf/utility.rb
#parse_plist(plist, symbol_keys: false) ⇒ Object
Parse a plist into a Ruby data structure. The plist parameter may be a String containing an XML plist, or a path to a plist file, or it may be a Pathname object pointing to a plist file. The plist files may be XML or binary.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/jamf/utility.rb', line 335 def parse_plist(plist, symbol_keys: false) require 'cfpropertylist' # did we get a string of xml, or a string pathname? case plist when String return CFPropertyList.native_types(CFPropertyList::List.new(data: plist).value, symbol_keys) if plist.include? '</plist>' plist = Pathname.new plist when Pathname true else raise ArgumentError, 'Argument must be a path (as a Pathname or String) or a String of XML' end # case plist # if we're here, its a Pathname raise Jamf::MissingDataError, "No such file: #{plist}" unless plist.file? CFPropertyList.native_types(CFPropertyList::List.new(file: plist).value, symbol_keys) end |