lib/simctl/device.rb in simctl-1.6.8 vs lib/simctl/device.rb in simctl-1.6.10

- old
+ new

@@ -1,10 +1,11 @@ require 'cfpropertylist' require 'ostruct' require 'simctl/device_launchctl' require 'simctl/device_path' require 'simctl/device_settings' +require 'simctl/keychain' require 'simctl/object' require 'simctl/status_bar' require 'timeout' module SimCtl @@ -25,11 +26,16 @@ # Returns true/false if the device is available # # @return [Bool] def available? - is_available !~ /unavailable/i + case is_available + when String + is_available !~ /unavailable/i + else + is_available + end end # Boots the device # # @return [void] @@ -44,13 +50,15 @@ SimCtl.delete_device(self) end # Returns the device type # - # @return [SimCtl::DeviceType] + # @return [SimCtl::DeviceType, String] def devicetype @devicetype ||= SimCtl.devicetype(identifier: plist.deviceType) + rescue + plist.deviceType end # Erases the device # # @return [void] @@ -93,10 +101,17 @@ # @ return [SimCtl::DeviceLaunchctl] def launchctl @launchctl ||= DeviceLaunchctl.new(self) end + # Returns the keychain bar object + # + # @return [SimCtl::keychain] + def keychain + @keychain ||= SimCtl::Keychain.new(self) + end + # Launches an app in the given device # # @param opts [Hash] options hash - `{ wait_for_debugger: true/false }` # @param identifier [String] the app identifier # @param args [Array] optional launch arguments @@ -175,12 +190,14 @@ SimCtl.reset_device name, devicetype, runtime end # Returns the runtime object # - # @return [SimCtl::Runtime] + # @return [SimCtl::Runtime, String] def runtime @runtime ||= SimCtl.runtime(identifier: plist.runtime) + rescue + plist.runtime end # Saves a screenshot to a file # # @param file Path where the screenshot should be saved to