lib/luffa/ios/ideviceinstaller.rb in luffa-1.0.5 vs lib/luffa/ios/ideviceinstaller.rb in luffa-1.0.6

- old
+ new

@@ -10,52 +10,50 @@ def initialize(ipa, bundle_id) @ipa = ipa @bundle_id = bundle_id end - def ideviceinstaller_available? + def self.ideviceinstaller_available? path = bin_path path and File.exist? bin_path end - def idevice_id_available? + def self.idevice_id_available? path = idevice_id_bin_path path and File.exist? path end def install(udid, options={}) - unless options.is_a? Hash + 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 - else - merged_options = DEFAULT_OPTIONS.merge(options) end uninstall(udid, merged_options) install_internal(udid, merged_options) end # Can only be called when RunLoop is available. - def physical_devices_for_testing(xcode_tools) + 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. - @physical_devices_for_testing ||= lambda { - devices = xcode_tools.instruments(:devices) - if 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 + 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 - }.call + else + devices + end end private DEFAULT_OPTIONS = { :timeout => 10.0, :tries => 2 }