Class: Luffa::IDeviceInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/luffa/ios/ideviceinstaller.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ipa, bundle_id) ⇒ IDeviceInstaller

Returns a new instance of IDeviceInstaller.



10
11
12
13
# File 'lib/luffa/ios/ideviceinstaller.rb', line 10

def initialize(ipa, bundle_id)
  @ipa = ipa
  @bundle_id = bundle_id
end

Instance Attribute Details

#bundle_idObject (readonly)

Returns the value of attribute bundle_id.



8
9
10
# File 'lib/luffa/ios/ideviceinstaller.rb', line 8

def bundle_id
  @bundle_id
end

#ipaObject (readonly)

Returns the value of attribute ipa.



7
8
9
# File 'lib/luffa/ios/ideviceinstaller.rb', line 7

def ipa
  @ipa
end

Class Method Details

.idevice_id_available?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/luffa/ios/ideviceinstaller.rb', line 20

def self.idevice_id_available?
  path = idevice_id_bin_path
  path and File.exist? path
end

.ideviceinstaller_available?Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/luffa/ios/ideviceinstaller.rb', line 15

def self.ideviceinstaller_available?
  path = bin_path
  path and File.exist? bin_path
end

.physical_devices_for_testing(xcode_tools) ⇒ Object

Can only be called when RunLoop is available.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/luffa/ios/ideviceinstaller.rb', line 39

def self.physical_devices_for_testing(xcode_tools)
  # Xcode 6 + iOS 8 - devices on the same network, whether development or
  # not, appear when calling $ xcrun instruments -s devices. For the
  # purposes of testing, we will only try to connect to devices that are
  # connected via USB.
  #
  # Also idevice_id, which ideviceinstaller relies on, will sometimes report
  # devices 2x which will cause ideviceinstaller to fail.
  devices = xcode_tools.instruments(:devices)
  if self.idevice_id_available?
    white_list = `#{idevice_id_bin_path} -l`.strip.split("\n")
    devices.select do | device |
      white_list.include?(device.udid) && white_list.count(device.udid) == 1
    end
  else
    devices
  end
end

Instance Method Details

#install(udid, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/luffa/ios/ideviceinstaller.rb', line 25

def install(udid, options={})
  if options.is_a? Hash
    merged_options = DEFAULT_OPTIONS.merge(options)
  else
    Luffa.log_warn 'API CHANGE: install now takes an options hash as 2nd arg'
    Luffa.log_warn "API CHANGE: ignoring '#{options}'; will use defaults"
    merged_options = DEFAULT_OPTIONS
  end

  uninstall(udid, merged_options)
  install_internal(udid, merged_options)
end