class RunLoop::Ipa
A model of the an .ipa - a application binary for iOS devices.
Attributes
The path to this .ipa. @!attribute [r] path @return [String] A path to this .ipa.
Public Class Methods
Return true if the path_to_ipa is probably an .ipa
# File lib/run_loop/ipa.rb, line 15 def self.is_ipa?(path_to_ipa) path_to_ipa.end_with?('.ipa') || RunLoop::Ipa.is_zip_archive?(path_to_ipa) end
Return true if the path_to_ipa to a zip archive
# File lib/run_loop/ipa.rb, line 8 def self.is_zip_archive?(path_to_ipa) hash = RunLoop::Shell.run_shell_command(["file", path_to_ipa], {log_cmd: true}) hash[:out][/Zip archive data/] end
Create a new ipa instance. @param [String] path_to_ipa The path the .ipa file. @return [Calabash::Ipa] A new ipa instance. @raise [RuntimeError] If the file does not exist. @raise [RuntimeError] If the file does not end in .ipa.
# File lib/run_loop/ipa.rb, line 29 def initialize(path_to_ipa) if !File.exist? path_to_ipa raise "Expected an ipa at '#{path_to_ipa}'" end if !RunLoop::Ipa.is_ipa?(path_to_ipa) raise "Expected '#{path_to_ipa}' have extension .ipa or be a zip archive" end @path = path_to_ipa end
Public Instance Methods
Returns the arches for the binary.
# File lib/run_loop/ipa.rb, line 76 def arches app.arches end
@!visibility private
# File lib/run_loop/ipa.rb, line 110 def build_version app.build_version end
The bundle identifier of this ipa. @return [String] A string representation of this ipa’s CFBundleIdentifier
# File lib/run_loop/ipa.rb, line 65 def bundle_identifier app.bundle_identifier end
Inspects the app’s executables for the server version @return a version instance
# File lib/run_loop/ipa.rb, line 82 def calabash_server_version app.calabash_server_version end
@!visibility private
# File lib/run_loop/ipa.rb, line 87 def codesign_info app.codesign_info end
@!visibility private
# File lib/run_loop/ipa.rb, line 92 def developer_signed? app.developer_signed? end
@!visibility private
# File lib/run_loop/ipa.rb, line 97 def distribution_signed? app.distribution_signed? end
Inspects the app’s Info.plist for the executable name. @return [String] The value of CFBundleExecutable.
# File lib/run_loop/ipa.rb, line 71 def executable_name app.executable_name end
@!visibility private
# File lib/run_loop/ipa.rb, line 59 def inspect to_s end
@!visibility private
# File lib/run_loop/ipa.rb, line 102 def marketing_version app.marketing_version end
@!visibility private
# File lib/run_loop/ipa.rb, line 41 def to_s cf_bundle_version = bundle_version cf_bundle_short_version = short_bundle_version if cf_bundle_version && cf_bundle_short_version version = "#{cf_bundle_version.to_s}/#{cf_bundle_short_version}" elsif cf_bundle_version version = cf_bundle_version.to_s elsif cf_bundle_short_version version = cf_bundle_short_version else version = "" end "#<IPA #{bundle_identifier} #{version} #{path}>" end
Private Instance Methods
@!visibility private
# File lib/run_loop/ipa.rb, line 146 def app @app ||= RunLoop::App.new(bundle_dir) end
@!visibility private
# File lib/run_loop/ipa.rb, line 137 def bundle_dir @bundle_dir ||= lambda do Dir.glob(File.join(payload_dir, '*')).detect do |f| File.directory?(f) && f.end_with?('.app') end end.call end
@!visibility private
# File lib/run_loop/ipa.rb, line 125 def payload_dir @payload_dir ||= lambda do FileUtils.cp(path, tmpdir) zip_path = File.join(tmpdir, File.basename(path)) Dir.chdir(tmpdir) do system('unzip', *['-q', zip_path]) end File.join(tmpdir, 'Payload') end.call end
@!visibility private
# File lib/run_loop/ipa.rb, line 151 def plist_buddy @plist_buddy ||= RunLoop::PlistBuddy.new end
@!visibility private
# File lib/run_loop/ipa.rb, line 120 def tmpdir @tmpdir ||= Dir.mktmpdir end