Class: DeviceAPI::IOS::IDeviceProvision
- Inherits:
-
Execution
- Object
- Execution
- DeviceAPI::IOS::IDeviceProvision
- Defined in:
- lib/device_api/ios/ideviceprovision.rb
Overview
Namespace for all methods encapsulating ideviceprovision calls
Class Method Summary collapse
-
.get_profile_info(file) ⇒ Hash
Gets information about a provisioning profile.
-
.has_profile?(options = {}) ⇒ Boolean
Checks to see if a profile is installed on the specified device.
-
.install_profile(options = {}) ⇒ Boolean, IDeviceProvisionError
Installs the specified profile to the device.
-
.list_profiles(serial) ⇒ Hash
Lists all profiles on the specified device.
-
.remove_profile(options = {}) ⇒ Boolean, IDeviceProvisionError
Removes the specified profile from the device.
Class Method Details
.get_profile_info(file) ⇒ Hash
Gets information about a provisioning profile
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/device_api/ios/ideviceprovision.rb', line 74 def self.get_profile_info(file) result = execute("ideviceprovision dump #{file}") raise IDeviceProvisionError.new(result.stderr) if result.exit != 0 lines = result.stdout.split("\n") info = {} lines.each do |l| if /(.*):\s+(.*)/.match(l) info[Regexp.last_match[1]] = Regexp.last_match[2] end end info end |
.has_profile?(options = {}) ⇒ Boolean
Checks to see if a profile is installed on the specified device
24 25 26 27 28 29 30 31 32 |
# File 'lib/device_api/ios/ideviceprovision.rb', line 24 def self.has_profile?( = {}) name = [:name] uuid = [:uuid] serial = [:serial] profiles = list_profiles(serial) profiles.key?(uuid) || profiles.value?(name) end |
.install_profile(options = {}) ⇒ Boolean, IDeviceProvisionError
Installs the specified profile to the device
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/device_api/ios/ideviceprovision.rb', line 56 def self.install_profile( = {}) serial = [:serial] file = [:file] info = get_profile_info(file) # Check to see if the profile has already been added to the device return true if has_profile?(serial: serial, uuid: info['UUID']) result = execute("ideviceprovision -u #{serial} install #{file}") raise IDeviceProvisionError.new(result.stderr) if result.exit != 0 true end |
.list_profiles(serial) ⇒ Hash
Lists all profiles on the specified device
10 11 12 13 14 15 16 |
# File 'lib/device_api/ios/ideviceprovision.rb', line 10 def self.list_profiles(serial) result = execute("ideviceprovision -u #{serial} list") raise IDeviceProvisionError.new(result.stderr) if result.exit != 0 Hash[result.stdout.split("\n").map { |a| b = a.split(' - '); [b[0], b[1]] }[1..-1]] end |
.remove_profile(options = {}) ⇒ Boolean, IDeviceProvisionError
Removes the specified profile from the device
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/device_api/ios/ideviceprovision.rb', line 39 def self.remove_profile( = {}) uuid = [:uuid] serial = [:serial] return true unless has_profile?(serial: serial, uuid: uuid) result = execute("ideviceprovision -u #{serial} remove #{uuid}") raise IDeviceProvisionError.new(result.stderr) if result.exit != 0 true end |