lib/run_loop/device.rb in run_loop-1.1.1.pre3 vs lib/run_loop/device.rb in run_loop-1.1.1.pre4
- old
+ new
@@ -15,8 +15,40 @@
end
@udid = udid
end
- end
+ # Is this device a simulator?
+ # @return [Boolean] Return true if this device is a simulator.
+ def simulator?
+ not physical_device?
+ end
-end
\ No newline at end of file
+ # Is this is a physical device?
+ # @return [Boolean] Return true if this is a physical device.
+ def physical_device?
+ (self.udid =~ /[a-f0-9]{40}/) == 0
+ end
+
+ # Returns and instruments-ready device identifier that is a suitable value
+ # for DEVICE_TARGET environment variable.
+ #
+ # @return [String] An instruments-ready device identifier.
+ # @raise [RuntimeError] If trying to obtain a instruments-ready identifier
+ # for a simulator when Xcode < 6.
+ def instruments_identifier(xcode_tools=RunLoop::XCTools.new)
+ if physical_device?
+ self.udid
+ else
+ unless xcode_tools.xcode_version_gte_6?
+ raise "Expected Xcode >= 6, but found version #{xcode_tools.version} - cannot create an identifier"
+ end
+ if self.version == RunLoop::Version.new('7.0.3')
+ version_part = self.version.to_s
+ else
+ version_part = "#{self.version.major}.#{self.version.minor}"
+ end
+ "#{self.name} (#{version_part} Simulator)"
+ end
+ end
+ end
+end