Class: DeviceAPI::IOS::Plistutil
- Inherits:
-
Execution
- Object
- Execution
- DeviceAPI::IOS::Plistutil
- Defined in:
- lib/device_api/ios/plistutil.rb
Overview
Namespace for all methods encapsulating plistutil calls
Class Method Summary collapse
-
.get_bundle_id_from_app(path) ⇒ Hash
Gets properties from the IPA and returns them in a hash.
-
.get_bundle_id_from_plist(plist) ⇒ Hash
Gets properties from the IPA and returns them in a hash.
- .parse_xml(xml) ⇒ Object
-
.plistutil_available? ⇒ Boolean
Check to ensure that plistutil is available.
Class Method Details
.get_bundle_id_from_app(path) ⇒ Hash
Gets properties from the IPA and returns them in a hash
22 23 24 25 |
# File 'lib/device_api/ios/plistutil.rb', line 22 def self.get_bundle_id_from_app(path) path = Signing.unpack_ipa(path) if Signing.is_ipa?(path) get_bundle_id_from_plist("#{path}/Info.plist") end |
.get_bundle_id_from_plist(plist) ⇒ Hash
Gets properties from the IPA and returns them in a hash
30 31 32 33 34 35 |
# File 'lib/device_api/ios/plistutil.rb', line 30 def self.get_bundle_id_from_plist(plist) raise PlistutilCommandError.new('plistutil not found') unless plistutil_available? result = execute("plistutil -i #{plist}") raise PlistutilCommandError.new(result.stderr) if result.exit != 0 parse_xml(result.stdout) end |
.parse_xml(xml) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/device_api/ios/plistutil.rb', line 37 def self.parse_xml(xml) info = Ox.parse(xml) nodes = info.locate('*/dict') values = {} last_key = nil nodes.first.nodes.each do |child| if child.value == 'key' if child.nodes.first == 'get-task-allow' values['get-task-allow'] = nodes.first.nodes[nodes.first.nodes.index(child)+1].value next end last_key = child.nodes.first elsif child.value == 'string' values[last_key] = child.nodes.first end end values end |
.plistutil_available? ⇒ Boolean
Check to ensure that plistutil is available
14 15 16 17 |
# File 'lib/device_api/ios/plistutil.rb', line 14 def self.plistutil_available? result = execute('which plistutil') result.exit == 0 end |