Class: DeviceAPI::IOS::IPAddress

Inherits:
Execution
  • Object
show all
Defined in:
lib/device_api/ios/ipaddress.rb

Overview

Namespace for all methods encapsulating idevice calls

Class Method Summary collapse

Class Method Details

.address(serial) ⇒ String

Get the IP Address from the installed app

Parameters:

  • serial (String)

    serial of the target device

Returns:

  • (String)

    IP Address if found



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/device_api/ios/ipaddress.rb', line 30

def self.address(serial)
  return nil unless installed?(serial)
  result = IDeviceDebug.run(serial: serial, bundle_id: ipaddress_bundle_id )

  ip_address = nil
  result.each do |line|
    if /"en0\/ipv4" = "(.*)"/.match(line)
      ip_address = Regexp.last_match[1]
    end
  end
  ip_address
end

.installed?(serial) ⇒ Boolean

Check to see if the IPAddress app is installed

Parameters:

  • serial (String)

    serial of the target device

Returns:

  • (Boolean)

    returns true if the app is installed



19
20
21
22
23
24
25
# File 'lib/device_api/ios/ipaddress.rb', line 19

def self.installed?(serial)
  if DeviceAPI::IOS::IDeviceInstaller.package_installed?( serial: serial, package: ipaddress_bundle_id )
    return true
  else
    warn IPAddressError.new('IP Address package not installed: Please see https://github.com/bbc/ios-test-helper')
  end
end

.ipaddress_bundle_idObject

Package name for the IP Address app



12
13
14
# File 'lib/device_api/ios/ipaddress.rb', line 12

def self.ipaddress_bundle_id
  'uk.co.bbc.titan.IPAddress'
end