Class: XCSim::GetDeviceList
- Inherits:
-
Object
- Object
- XCSim::GetDeviceList
- Defined in:
- lib/xcsim/rbList.rb
Overview
A class encapsulating logic of searching available OS verions / device models / installed apps in #xcsim function (i.e. implementation of #xcsim list mode)
Instance Method Summary collapse
-
#allDevices ⇒ Object
Returns an array of DeviceListItem corresponding to all installed iOS Simulators.
-
#initialize(deviceSet) ⇒ GetDeviceList
constructor
Initializes a GetDeviceList instance with a given device set of OSDevices class.
-
#withPattern(pattern) ⇒ Object
Performs search for the iOS simulators matching the provided pattern.
Constructor Details
#initialize(deviceSet) ⇒ GetDeviceList
Initializes a GetDeviceList instance with a given device set of OSDevices class
54 55 56 |
# File 'lib/xcsim/rbList.rb', line 54 def initialize(deviceSet) @deviceSet = deviceSet end |
Instance Method Details
#allDevices ⇒ Object
Returns an array of DeviceListItem corresponding to all installed iOS Simulators
89 90 91 92 93 94 95 96 |
# File 'lib/xcsim/rbList.rb', line 89 def allDevices @deviceSet.values.map do |os| os.devices.values.map do |device| DeviceListItem.new(os, device, XCSim::parseInstalledBundles(device).values) end end .flatten end |
#withPattern(pattern) ⇒ Object
Performs search for the iOS simulators matching the provided pattern. See #xcsim description (List Mode section) for more info.
Returns an array of DeviceListItem
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/xcsim/rbList.rb', line 62 def withPattern(pattern) if pattern.length == 0 return allDevices else pattern = parsePattern(pattern) matchingOSes = getMatchingOSList(pattern[:os]) devicePairs = matchingOSes .map{ |os| os.devices.values.map{ |d| {:os => os, :device => d} } } .flatten # try finding a strict match first (disambiguate "iPad Air" from "iPad Air 2") # find partial matches otherwise matchingDevices = strictDeviceMatches(devicePairs, pattern[:device]) || partialDeviceMatches(devicePairs, pattern[:device]) || [] return matchingDevices.map do |pair| DeviceListItem.new(pair[:os], pair[:device], XCSim::parseInstalledBundles(pair[:device]).values) end .flatten end end |