Sha256: ae016b0e208dc35705a1a216c009ba169739b7db9c4feafa087d7d8bbf750c9c

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require 'shellwords'

module SimCtl
  class Command
    module Create
      # Creates a device
      #
      # @param name [String] name of the new device
      # @param devicetype [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
      def create_device(name, devicetype, runtime)
        runtime = runtime(name: runtime) unless runtime.is_a?(Runtime)
        devicetype = devicetype(name: devicetype) unless devicetype.is_a?(DeviceType)
        raise "Invalid runtime: #{runtime}" unless runtime.is_a?(Runtime)
        raise "Invalid devicetype: #{devicetype}" unless devicetype.is_a?(DeviceType)
        device = Executor.execute(command_for('create', Shellwords.shellescape(name), devicetype.identifier, runtime.identifier)) do |identifier|
          device(udid: identifier)
        end
        device.wait! {|d| d.state == :shutdown && File.exists?(d.path.device_plist)}
        device
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simctl-1.5.8 lib/simctl/command/create.rb
simctl-1.5.7 lib/simctl/command/create.rb
simctl-1.5.6 lib/simctl/command/create.rb
simctl-1.5.5 lib/simctl/command/create.rb
simctl-1.5.4 lib/simctl/command/create.rb
simctl-1.5.3 lib/simctl/command/create.rb
simctl-1.5.2 lib/simctl/command/create.rb