lib/simctl/device.rb in simctl-1.1.0 vs lib/simctl/device.rb in simctl-1.2.0
- old
+ new
@@ -1,5 +1,7 @@
+require 'cfpropertylist'
+require 'ostruct'
require 'simctl/object'
require 'timeout'
module SimCtl
class Device < Object
@@ -11,22 +13,34 @@
def delete!
SimCtl.delete_device(self)
end
+ def devicetype
+ @devicetype ||= SimCtl.devicetype(identifier: plist.deviceType)
+ end
+
def erase!
SimCtl.erase_device(self)
end
def kill!
SimCtl.kill_device(self)
end
- def launch!
- SimCtl.launch_device(self)
+ def launch!(scale=1.0)
+ SimCtl.launch_device(self, scale)
end
+ def rename!(name)
+ SimCtl.rename_device(self, name)
+ end
+
+ def runtime
+ @runtime ||= SimCtl.runtime(identifier: plist.runtime)
+ end
+
def shutdown!
SimCtl.shutdown_device(self)
end
def state
@@ -38,7 +52,18 @@
loop do
break if yield SimCtl.device(udid: udid)
end
end
end
+
+ def ==(other)
+ other.udid == udid
+ end
+
+ private
+
+ def plist
+ @plist ||= OpenStruct.new(CFPropertyList.native_types(CFPropertyList::List.new(file: File.join(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices', udid, 'device.plist')).value))
+ end
+
end
end