Module: SimCtl::Command::Reset

Included in:
SimCtl::Command
Defined in:
lib/simctl/command/reset.rb

Instance Method Summary collapse

Instance Method Details

#reset_device(name, device_type, runtime) {|exception| ... } ⇒ SimCtl::Device

Kill, shutdown, delete and create a device

Parameters:

  • name (String)

    name of the new device

  • device_type (SimCtl::DeviceType)

    device type of the new device

  • runtime (SimCtl::Runtime)

    runtime of the new device

Yields:

  • (exception)

    an exception that might happen during shutdown/delete of the old device

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simctl/command/reset.rb', line 11

def reset_device(name, device_type, runtime)
  begin
    list_devices.where(name: name, os: runtime.identifier).each do |device|
      device.kill
      device.shutdown if device.state != :shutdown
      device.wait { |d| d.state == :shutdown }
      device.delete
    end
  rescue Exception => exception
    yield exception if block_given?
  end
  device = create_device name, device_type, runtime
  device.wait { |d| d.state == :shutdown }
  device
end