class RunLoop::Ipa

A model of the an .ipa - a application binary for iOS devices.

Attributes

path[R]

The path to this .ipa. @!attribute [r] path @return [String] A path to this .ipa.

Public Class Methods

is_ipa?(path_to_ipa) click to toggle source

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
is_zip_archive?(path_to_ipa) click to toggle source

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
new(path_to_ipa) click to toggle source

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

arches() click to toggle source

Returns the arches for the binary.

# File lib/run_loop/ipa.rb, line 76
def arches
  app.arches
end
build_version() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 110
def build_version
  app.build_version
end
Also aliased as: bundle_version
bundle_identifier() click to toggle source

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
bundle_version()
Alias for: build_version
calabash_server_version() click to toggle source

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
codesign_info() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 87
def codesign_info
  app.codesign_info
end
developer_signed?() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 92
def developer_signed?
  app.developer_signed?
end
distribution_signed?() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 97
def distribution_signed?
  app.distribution_signed?
end
executable_name() click to toggle source

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
inspect() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 59
def inspect
  to_s
end
marketing_version() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 102
def marketing_version
  app.marketing_version
end
Also aliased as: short_bundle_version
short_bundle_version()
Alias for: marketing_version
to_s() click to toggle source

@!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

app() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 146
def app
  @app ||= RunLoop::App.new(bundle_dir)
end
bundle_dir() click to toggle source

@!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
payload_dir() click to toggle source

@!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
plist_buddy() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 151
def plist_buddy
  @plist_buddy ||= RunLoop::PlistBuddy.new
end
tmpdir() click to toggle source

@!visibility private

# File lib/run_loop/ipa.rb, line 120
def tmpdir
  @tmpdir ||= Dir.mktmpdir
end