lib/simctl/device.rb in simctl-1.2.3 vs lib/simctl/device.rb in simctl-1.3.0

- old
+ new

@@ -1,7 +1,8 @@ require 'cfpropertylist' require 'ostruct' +require 'simctl/device_path' require 'simctl/object' require 'timeout' module SimCtl class Device < Object @@ -17,26 +18,52 @@ def devicetype @devicetype ||= SimCtl.devicetype(identifier: plist.deviceType) end + def disable_keyboard_helpers! + path.edit path.preferences_plist do |plist| + %w( + KeyboardPeriodShortcut + KeyboardAutocapitalization + KeyboardCheckSpelling + KeyboardAssistant + KeyboardAutocorrection + KeyboardPrediction + KeyboardShowPredictionBar + KeyboardCapsLock + ).each do |key| + plist[key] = false + end + plist + end + end + def erase! SimCtl.erase_device(self) end def kill! SimCtl.kill_device(self) end - def launch!(scale=1.0) - SimCtl.launch_device(self, scale) + def launch!(scale=1.0, opts={}) + SimCtl.launch_device(self, scale, opts) end + def path + @path ||= DevicePath.new(udid) + end + def rename!(name) SimCtl.rename_device(self, name) end + def reset! + SimCtl.reset_device name, devicetype, runtime + end + def runtime @runtime ||= SimCtl.runtime(identifier: plist.runtime) end def shutdown! @@ -54,20 +81,18 @@ end end end def ==(other) + return false if other.nil? + return false unless other.kind_of? Device other.udid == udid end private def plist - @plist ||= OpenStruct.new(CFPropertyList.native_types(CFPropertyList::List.new(file: plist_path).value)) - end - - def plist_path - File.join(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices', udid, 'device.plist') + @plist ||= OpenStruct.new(CFPropertyList.native_types(CFPropertyList::List.new(file: path.device_plist).value)) end end end