class RunLoop::DeviceAgent::Runner

@!visibility private

Attributes

device[R]

@!visibility private

Public Class Methods

default_cbxdevice() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 66
def self.default_cbxdevice
  cbx = File.join(self.device_agent_dir, "ipa", "DeviceAgent-Runner.app")

  if !File.exist?(cbx)
    self.expand_runner_archive("#{cbx}.zip")
  else
    cbx
  end
end
default_cbxsim() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 77
def self.default_cbxsim
  cbx = File.join(self.device_agent_dir, "app", "DeviceAgent-Runner.app")

  if !File.exist?(cbx)
    self.expand_runner_archive("#{cbx}.zip")
  else
    cbx
  end
end
detect_cbxdevice() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 43
      def self.detect_cbxdevice
        @@cbxdevice ||= begin
          from_env = RunLoop::Environment.cbxdevice

          if from_env
            if File.exist?(from_env)
              from_env
            else
              raise RuntimeError, %Q[
CBXDEVICE environment variable defined:

  #{from_env}

but runner does not exist at that path.
]
            end
          else
            self.default_cbxdevice
          end
        end
      end
detect_cbxsim() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 20
      def self.detect_cbxsim
        @@cbxsim ||= begin
          from_env = RunLoop::Environment.cbxsim

          if from_env
            if File.exist?(from_env)
              from_env
            else
              raise RuntimeError, %Q[
CBXSIM environment variable defined:

  #{from_env}

but runner does not exist at that path.
]
            end
          else
            self.default_cbxsim
          end
        end
      end
device_agent_dir() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 15
def self.device_agent_dir
  @@device_agent_dir ||= File.expand_path(File.dirname(__FILE__))
end
expand_runner_archive(archive) click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 88
def self.expand_runner_archive(archive)
  dir = File.dirname(archive)
  options = { :log_cmd => true }
  Dir.chdir(dir) do
    Shell.run_shell_command(["ditto", "-xk", File.basename(archive), "."], options)
  end
  File.join(dir, "DeviceAgent-Runner.app")
end
new(device) click to toggle source

@!visibility private @param [RunLoop::Device] device the target device

# File lib/run_loop/device_agent/runner.rb, line 102
def initialize(device)
  @device = device
end

Public Instance Methods

port() click to toggle source
# File lib/run_loop/device_agent/runner.rb, line 117
def port
  @port ||= begin
    if device.physical_device?
      27753
    else
      RunLoop::Environment.port
    end
  end
end
runner() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 107
def runner
  @runner ||= begin
    if device.physical_device?
      RunLoop::DeviceAgent::Runner.detect_cbxdevice
    else
      RunLoop::DeviceAgent::Runner.detect_cbxsim
    end
  end
end
tester() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 128
def tester
  @tester ||= File.join(runner, "PlugIns", "DeviceAgent.xctest")
end
version() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 133
def version
  @version ||= lambda do
    short = pbuddy.plist_read("CFBundleShortVersionString", info_plist)
    build = pbuddy.plist_read("CFBundleVersion", info_plist)
    str = "#{short}.pre#{build}"
    RunLoop::Version.new(str)
  end.call
end

Private Instance Methods

info_plist() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 145
def info_plist
  @info_plist ||= File.join(runner, "Info.plist")
end
pbuddy() click to toggle source

@!visibility private

# File lib/run_loop/device_agent/runner.rb, line 150
def pbuddy
  @pbuddy ||= RunLoop::PlistBuddy.new
end