Sha256: 7900eb0cc03c3b8f5fd10cb62a161eb8f5bd883f372e2392b30c3283af2d7c52

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 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)
        command = command_for('create', Shellwords.shellescape(name), devicetype.identifier, runtime.identifier)
        device = Executor.execute(command) do |identifier|
          device(udid: identifier)
        end
        device.wait { |d| d.state == :shutdown && File.exist?(d.path.device_plist) }
        device
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simctl-1.6.10 lib/simctl/command/create.rb
simctl-1.6.8 lib/simctl/command/create.rb
simctl-1.6.7 lib/simctl/command/create.rb
simctl-1.6.6 lib/simctl/command/create.rb
simctl-1.6.5 lib/simctl/command/create.rb
simctl-1.6.4 lib/simctl/command/create.rb
simctl-1.6.3 lib/simctl/command/create.rb