Class: SimCtl::DevicePath

Inherits:
Object
  • Object
show all
Defined in:
lib/simctl/device_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(udid) ⇒ DevicePath

Returns a new instance of DevicePath.



7
8
9
10
11
# File 'lib/simctl/device_path.rb', line 7

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

Instance Attribute Details

#device_plistObject (readonly)

Returns the value of attribute device_plist.



5
6
7
# File 'lib/simctl/device_path.rb', line 5

def device_plist
  @device_plist
end

#homeObject (readonly)

Returns the value of attribute home.



5
6
7
# File 'lib/simctl/device_path.rb', line 5

def home
  @home
end

#preferences_plistObject (readonly)

Returns the value of attribute preferences_plist.



5
6
7
# File 'lib/simctl/device_path.rb', line 5

def preferences_plist
  @preferences_plist
end

Instance Method Details

#edit(path, &block) ⇒ Object



13
14
15
16
17
18
# File 'lib/simctl/device_path.rb', line 13

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