Sha256: 074e870a362a0a82f5cec6f8f5d3d1f2204e97f2218a984154bf8cb871177c43

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

require 'cfpropertylist'

module SimCtl
  module Helper
    # Edit some plist
    #
    # @param [String] Path to the plist
    # @return [void]
    # @yield [Hash] The hash of the plist. Modifications will be written to the file.
    def edit_plist(path, &block)
      plist = File.exists?(path) ? CFPropertyList::List.new(file: path) : CFPropertyList::List.new
      content = CFPropertyList.native_types(plist.value) || {}
      yield content
      plist.value = CFPropertyList.guess(content)
      plist.save(path, CFPropertyList::List::FORMAT_BINARY)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simctl-1.4.0 lib/simctl/helper.rb