Sha256: 8e0b2d390fc9b3feaf077428cb8dcc14f9281c2a0cc1aa356d8b6180484090e8

Contents?: true

Size: 1021 Bytes

Versions: 16

Compression:

Stored size: 1021 Bytes

Contents

module SimCtl
  class Command
    module Reset
      # Kill, shutdown, delete and create a device
      #
      # @param name [String] name of the new device
      # @param device_type [SimCtl::DeviceType] device type of the new device
      # @param runtime [SimCtl::Runtime] runtime of the new device
      # @return [SimCtl::Device] the device that was created
      # @yield [exception] an exception that might happen during shutdown/delete of the old device
      def reset_device(name, device_type, runtime)
        begin
          list_devices.where(name: name, os: runtime.name).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
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
simctl-1.5.8 lib/simctl/command/reset.rb
simctl-1.5.7 lib/simctl/command/reset.rb
simctl-1.5.6 lib/simctl/command/reset.rb
simctl-1.5.5 lib/simctl/command/reset.rb
simctl-1.5.4 lib/simctl/command/reset.rb
simctl-1.5.3 lib/simctl/command/reset.rb
simctl-1.5.2 lib/simctl/command/reset.rb
simctl-1.5.1 lib/simctl/command/reset.rb
simctl-1.5.0 lib/simctl/command/reset.rb
simctl-1.4.1 lib/simctl/command/reset.rb
simctl-1.4.0 lib/simctl/command/reset.rb
simctl-1.3.1 lib/simctl/command/reset.rb
simctl-1.3.0 lib/simctl/command/reset.rb
simctl-1.2.3 lib/simctl/command/reset.rb
simctl-1.2.2 lib/simctl/command/reset.rb
simctl-1.2.1 lib/simctl/command/reset.rb