Sha256: 1ec10a9e517d6ae56530476f52e3f7dad4f5c1984994a61a7a9f34c77aad6d58

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

require 'simctl/object'

module SimCtl
  class DevicePath
    attr_reader :device_plist, :home, :preferences_plist

    def initialize(udid)
      @home = File.join(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices', udid)
      @device_plist = File.join(@home, 'device.plist')
      @preferences_plist = File.join(@home, 'data/Library/Preferences/com.apple.Preferences.plist')
    end

    def edit(path, &block)
      plist = File.exists?(path) ? CFPropertyList::List.new(file: path) : CFPropertyList::List.new
      content = CFPropertyList.native_types(plist.value) || {}
      plist.value = CFPropertyList.guess(yield content)
      plist.save(path, CFPropertyList::List::FORMAT_BINARY)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simctl-1.3.1 lib/simctl/device_path.rb
simctl-1.3.0 lib/simctl/device_path.rb