Class: RunLoop::PhysicalDevice::IOSDeviceManager

Inherits:
LifeCycle
  • Object
show all
Defined in:
lib/run_loop/physical_device/ios_device_manager.rb

Constant Summary

Constants included from Shell

Shell::DEFAULT_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Shell

run_shell_command, #run_shell_command

Methods included from Encoding

#transliterate

Constructor Details

#initialize(device) ⇒ IOSDeviceManager


18
19
20
21
22
23
# File 'lib/run_loop/physical_device/ios_device_manager.rb', line 18

def initialize(device)
  super(device)

  # Expands the Frameworks.zip if necessary.
  RunLoop::DeviceAgent::Frameworks.instance.install
end

Class Method Details

.executable_pathObject

Path to tool.


14
15
16
# File 'lib/run_loop/physical_device/ios_device_manager.rb', line 14

def self.executable_path
  RunLoop::DeviceAgent::IOSDeviceManager.ios_device_manager
end

.tool_is_installed?Boolean

Is the tool installed?


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

def self.tool_is_installed?
  File.exist?(IOSDeviceManager.executable_path)
end

Instance Method Details

#app_installed?(bundle_id) ⇒ Boolean


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/run_loop/physical_device/ios_device_manager.rb', line 25

def app_installed?(bundle_id)
  args = [
    IOSDeviceManager.executable_path,
    "is_installed",
    "-d", device.udid,
    "-b", bundle_id
  ]

  options = { :log_cmd => true }
  hash = run_shell_command(args, options)

  # TODO: error reporting
  hash[:exit_status] == 0
end

#install_app(app_or_ipa) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/run_loop/physical_device/ios_device_manager.rb', line 40

def install_app(app_or_ipa)
  app = app_or_ipa
  if is_ipa?(app)
    app = app_or_ipa.app
  end

  code_sign_identity = RunLoop::Environment.code_sign_identity
  if !code_sign_identity
    code_sign_identity = "iPhone Developer"
  end

  args = [
    IOSDeviceManager.executable_path,
    "install",
    "-d", device.udid,
    "-a", app.path,
    "-c", code_sign_identity
  ]

  options = { :log_cmd => true }
  hash = run_shell_command(args, options)

  # TODO: error reporting
  if hash[:exit_status] == 0
    true
  else
    puts hash[:out]
    false
  end
end

#uninstall_app(bundle_id) ⇒ Object


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

def uninstall_app(bundle_id)
  return true if !app_installed?(bundle_id)

  args = [
    IOSDeviceManager.executable_path,
    "uninstall",
    "-d", device.udid,
    "-b", bundle_id
  ]

  options = { :log_cmd => true }
  hash = run_shell_command(args, options)

  # TODO: error reporting
  hash[:exit_status] == 0
end