lib/run_loop/device.rb in run_loop-1.3.0 vs lib/run_loop/device.rb in run_loop-1.3.1

- old
+ new

@@ -3,10 +3,13 @@ attr_reader :name attr_reader :version attr_reader :udid attr_reader :state + attr_reader :simulator_root_dir + attr_reader :simulator_accessibility_plist_path + attr_reader :simulator_preferences_plist_path # Create a new device. # # @param [String] name The name of the device. For sims this should be # 'iPhone 5s' and for physical devices it will be the name the user gave @@ -84,7 +87,32 @@ end else raise 'Finding the instruction set of a device requires a third-party tool like ideviceinfo' end end + + def simulator_root_dir + @simulator_root_dir ||= lambda { + return nil if physical_device? + File.join(CORE_SIMULATOR_DEVICE_DIR, udid) + }.call + end + + def simulator_accessibility_plist_path + @simulator_accessibility_plist_path ||= lambda { + return nil if physical_device? + File.join(simulator_root_dir, 'data/Library/Preferences/com.apple.Accessibility.plist') + }.call + end + + def simulator_preferences_plist_path + @simulator_preferences_plist_path ||= lambda { + return nil if physical_device? + File.join(simulator_root_dir, 'data/Library/Preferences/com.apple.Preferences.plist') + }.call + end + + private + + CORE_SIMULATOR_DEVICE_DIR = File.expand_path('~/Library/Developer/CoreSimulator/Devices') end end