Class: XCSim::GetBundle

Inherits:
Object
  • Object
show all
Defined in:
lib/xcsim/rbBundleInfo.rb

Overview

A class encapsulating logic of searching for an applciation bundle in #xcsim function (i.e. implementation of #xcsim bundle mode)

Instance Method Summary collapse

Constructor Details

#initialize(deviceSet) ⇒ GetBundle

Initializes a GetBundle instance with a given device set of OSDevices type



100
101
102
# File 'lib/xcsim/rbBundleInfo.rb', line 100

def initialize(deviceSet)
  @deviceSet = deviceSet
end

Instance Method Details

#withOptions(options) ⇒ Object

Performs search for the application bundle matching the provided options. See #xcsim description (Bundle Mode section) for more info.

Returns a BundleInfo object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/xcsim/rbBundleInfo.rb', line 108

def withOptions(options)
  bundleID = options[:bundleID]

  if bundleID == nil
    raise ArgumentError
  end

  os = osNamed(options[:os] || XCSim::defaultOSName)
  device = deviceNamed(os, options[:device] || XCSim::defaultDeviceName)
  bundles = XCSim::parseInstalledBundles(device).values

  matchingBundles = bundles.select { |bundle| bundle.bundleID.end_with? bundleID }

  if matchingBundles.count > 1
    raise NonUniqueBundleIDError.new(device, bundleID, matchingBundles.map { |b| b.bundleID })
  elsif matchingBundles.empty?
    raise BundleNotFoundError.new(os, device, bundleID)
  else
    return matchingBundles.first
  end
end