Class: RunLoop::Ipa

Inherits:
Object
  • Object
show all
Defined in:
lib/run_loop/ipa.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_to_ipa) ⇒ Calabash::Ipa

Create a new ipa instance.

Parameters:

  • path_to_ipa (String)

    The path the .ipa file.

Raises:

  • (RuntimeError)

    If the file does not exist.

  • (RuntimeError)

    If the file does not end in .ipa.


22
23
24
25
26
27
28
29
30
31
# File 'lib/run_loop/ipa.rb', line 22

def initialize(path_to_ipa)
  unless File.exist? path_to_ipa
    raise "Expected an ipa at '#{path_to_ipa}'"
  end

  unless path_to_ipa.end_with?('.ipa')
    raise "Expected '#{path_to_ipa}' to be an .ipa"
  end
  @path = path_to_ipa
end

Instance Attribute Details

#bundle_identifierString (readonly)

The bundle identifier of this ipa.

Returns:

  • (String)

    A string representation of this ipa's CFBundleIdentifier

Raises:

  • (RuntimeError)

    If ipa does not expand into a Payload/<app name>.app directory.

  • (RuntimeError)

    If an Info.plist does exist in the .app.


15
16
17
# File 'lib/run_loop/ipa.rb', line 15

def bundle_identifier
  @bundle_identifier
end

#pathString (readonly)

The path to this .ipa.

Returns:

  • (String)

    A path to this .ipa.


9
10
11
# File 'lib/run_loop/ipa.rb', line 9

def path
  @path
end

Instance Method Details

#executable_nameString

Inspects the app's Info.plist for the executable name.

Returns:

  • (String)

    The value of CFBundleExecutable.

Raises:

  • (RuntimeError)

    If the plist cannot be read or the CFBundleExecutable is empty or does not exist.


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/run_loop/ipa.rb', line 71

def executable_name
  if bundle_dir.nil? || !File.exist?(bundle_dir)
    raise "Expected a '#{File.basename(path).split('.').first}.app'\nat path '#{payload_dir}'"
  end

  @executable_name ||= lambda {
    info_plist_path = File.join(bundle_dir, 'Info.plist')
    unless File.exist? info_plist_path
      raise "Expected an 'Info.plist' at '#{bundle_dir}'"
    end
    name = plist_buddy.plist_read('CFBundleExecutable', info_plist_path)

    unless name
      raise "Expected key 'CFBundleExecutable' in '#{info_plist_path}'"
    end
    name
  }.call
end