simctl 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/simctl/command.rb +9 -0
- data/lib/simctl/command/boot.rb +1 -3
- data/lib/simctl/command/create.rb +1 -3
- data/lib/simctl/command/delete.rb +1 -3
- data/lib/simctl/command/erase.rb +1 -3
- data/lib/simctl/command/install.rb +1 -1
- data/lib/simctl/command/launch.rb +4 -2
- data/lib/simctl/command/list.rb +3 -5
- data/lib/simctl/command/rename.rb +1 -3
- data/lib/simctl/command/shutdown.rb +1 -3
- data/lib/simctl/device_path.rb +8 -1
- data/lib/simctl/version.rb +1 -1
- data/test/simctl/{command/crud_test.rb → crud_test.rb} +1 -1
- data/test/simctl/executor_test.rb +22 -0
- data/test/simctl/{command/list_test.rb → list_test.rb} +1 -1
- data/test/simctl/{command/readme_test.rb → readme_test.rb} +1 -1
- data/test/test_helper.rb +4 -0
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f923baf8dbf6166ce07d1890414262712aa65756
|
4
|
+
data.tar.gz: ce8194686b27910c708edd304b0ce55366c0c577
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b20bc6edfabde97837da052ae1d2b951724039111e1493b71eec2f17664155747a854a7053e8a49f4dfef9cce4d49a1ad46e206abfb47c21f95ac0270d64582
|
7
|
+
data.tar.gz: 947909872a6e4b6bb082f43699362c19021ca1d072fc5abb7fa85db1f5f1097e90420426bdb26706e33a7a60e84150e6cc5ca04cc18a25fee804c68b0c37674b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/simctl/command.rb
CHANGED
@@ -13,6 +13,8 @@ require 'simctl/executor'
|
|
13
13
|
|
14
14
|
module SimCtl
|
15
15
|
class Command
|
16
|
+
attr_accessor :device_set_path
|
17
|
+
|
16
18
|
include SimCtl::Command::Boot
|
17
19
|
include SimCtl::Command::Create
|
18
20
|
include SimCtl::Command::Delete
|
@@ -24,5 +26,12 @@ module SimCtl
|
|
24
26
|
include SimCtl::Command::Rename
|
25
27
|
include SimCtl::Command::Reset
|
26
28
|
include SimCtl::Command::Shutdown
|
29
|
+
|
30
|
+
def command_for(*arguments)
|
31
|
+
command = %w[xcrun simctl]
|
32
|
+
command += ['--set', device_set_path] unless device_set_path.nil?
|
33
|
+
command += arguments
|
34
|
+
command
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
data/lib/simctl/command/boot.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module SimCtl
|
2
2
|
class Command
|
3
3
|
module Boot
|
4
|
-
COMMAND = %w[xcrun simctl boot]
|
5
|
-
|
6
4
|
# Boots a device
|
7
5
|
#
|
8
6
|
# @param device [SimCtl::Device] the device to boot
|
9
7
|
# @return [void]
|
10
8
|
def boot_device(device)
|
11
|
-
Executor.execute(
|
9
|
+
Executor.execute(command_for('boot', device.udid))
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -3,8 +3,6 @@ require 'shellwords'
|
|
3
3
|
module SimCtl
|
4
4
|
class Command
|
5
5
|
module Create
|
6
|
-
COMMAND = %w[xcrun simctl create]
|
7
|
-
|
8
6
|
# Creates a device
|
9
7
|
#
|
10
8
|
# @param name [String] name of the new device
|
@@ -16,7 +14,7 @@ module SimCtl
|
|
16
14
|
devicetype = devicetype(name: devicetype) unless devicetype.is_a?(DeviceType)
|
17
15
|
raise "Invalid runtime: #{runtime}" unless runtime.is_a?(Runtime)
|
18
16
|
raise "Invalid devicetype: #{devicetype}" unless devicetype.is_a?(DeviceType)
|
19
|
-
device = Executor.execute(
|
17
|
+
device = Executor.execute(command_for('create', Shellwords.shellescape(name), devicetype.identifier, runtime.identifier)) do |identifier|
|
20
18
|
device(udid: identifier)
|
21
19
|
end
|
22
20
|
device.wait! {|d| d.state == :shutdown && File.exists?(d.path.device_plist)}
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module SimCtl
|
2
2
|
class Command
|
3
3
|
module Delete
|
4
|
-
COMMAND = %w[xcrun simctl delete]
|
5
|
-
|
6
4
|
# Delete a device
|
7
5
|
#
|
8
6
|
# @param device [SimCtl::Device] the device to delete
|
9
7
|
# @return [void]
|
10
8
|
def delete_device(device)
|
11
|
-
Executor.execute(
|
9
|
+
Executor.execute(command_for('delete', device.udid))
|
12
10
|
end
|
13
11
|
|
14
12
|
# Delete all devices
|
data/lib/simctl/command/erase.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module SimCtl
|
2
2
|
class Command
|
3
3
|
module Erase
|
4
|
-
COMMAND = %w[xcrun simctl erase]
|
5
|
-
|
6
4
|
# Erase a device
|
7
5
|
#
|
8
6
|
# @param device [SimCtl::Device] the device to erase
|
9
7
|
# @return [void]
|
10
8
|
def erase_device(device)
|
11
|
-
Executor.execute(
|
9
|
+
Executor.execute(command_for('erase', device.udid))
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -11,7 +11,7 @@ module SimCtl
|
|
11
11
|
# @param path Absolute path to the app that should be installed
|
12
12
|
# @return [void]
|
13
13
|
def install_app(device, path)
|
14
|
-
Executor.execute(
|
14
|
+
Executor.execute(command_for('install', device.udid, Shellwords.shellescape(path)))
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -20,7 +20,9 @@ module SimCtl
|
|
20
20
|
'-ConnectHardwareKeyboard' => 1,
|
21
21
|
'-CurrentDeviceUDID' => device.udid,
|
22
22
|
"-SimulatorWindowLastScale-#{device.devicetype.identifier}" => scale,
|
23
|
-
}
|
23
|
+
}
|
24
|
+
args.merge!({ '-DeviceSetPath' => SimCtl.device_set_path }) unless SimCtl.device_set_path.nil?
|
25
|
+
args = args.merge(opts).zip.flatten.join(' ')
|
24
26
|
command = "open -Fgn #{XCODE_HOME}/Applications/Simulator.app --args #{args}"
|
25
27
|
system command
|
26
28
|
end
|
@@ -35,7 +37,7 @@ module SimCtl
|
|
35
37
|
def launch_app(device, identifier, args=[], opts={})
|
36
38
|
launch_args = args.map {|arg| Shellwords.shellescape arg}
|
37
39
|
launch_opts = opts[:wait_for_debugger] ? '-w' : ''
|
38
|
-
Executor.execute(
|
40
|
+
Executor.execute(command_for('launch', launch_opts, device.udid, identifier, launch_args))
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
data/lib/simctl/command/list.rb
CHANGED
@@ -3,8 +3,6 @@ module SimCtl
|
|
3
3
|
class RuntimeNotFound < StandardError; end
|
4
4
|
class Command
|
5
5
|
module List
|
6
|
-
COMMAND = %w[xcrun simctl list -j]
|
7
|
-
|
8
6
|
# Find a device
|
9
7
|
#
|
10
8
|
# @param filter [Hash] the filter
|
@@ -26,7 +24,7 @@ module SimCtl
|
|
26
24
|
#
|
27
25
|
# @return [SimCtl::List] a list of SimCtl::Device objects
|
28
26
|
def list_devices
|
29
|
-
Executor.execute(
|
27
|
+
Executor.execute(command_for('list', '-j', 'devices')) do |json|
|
30
28
|
SimCtl::List.new(json['devices'].map {|os, devices| devices.map {|device| Device.new(device.merge(os: os))}}.flatten)
|
31
29
|
end
|
32
30
|
end
|
@@ -35,7 +33,7 @@ module SimCtl
|
|
35
33
|
#
|
36
34
|
# @return [SimCtl::List] a list of SimCtl::DeviceType objects
|
37
35
|
def list_devicetypes
|
38
|
-
Executor.execute(
|
36
|
+
Executor.execute(command_for('list', '-j', 'devicetypes')) do |json|
|
39
37
|
SimCtl::List.new(json['devicetypes'].map {|devicetype| DeviceType.new(devicetype)})
|
40
38
|
end
|
41
39
|
end
|
@@ -44,7 +42,7 @@ module SimCtl
|
|
44
42
|
#
|
45
43
|
# @return [SimCtl::List] a list of SimCtl::Runtime objects
|
46
44
|
def list_runtimes
|
47
|
-
Executor.execute(
|
45
|
+
Executor.execute(command_for('list', '-j', 'runtimes')) do |json|
|
48
46
|
SimCtl::List.new(json['runtimes'].map {|runtime| Runtime.new(runtime)})
|
49
47
|
end
|
50
48
|
end
|
@@ -3,15 +3,13 @@ require 'shellwords'
|
|
3
3
|
module SimCtl
|
4
4
|
class Command
|
5
5
|
module Rename
|
6
|
-
COMMAND = %w[xcrun simctl rename]
|
7
|
-
|
8
6
|
# Boots a device
|
9
7
|
#
|
10
8
|
# @param device [SimCtl::Device] the device to boot
|
11
9
|
# @param name [String] the new device name
|
12
10
|
# @return [void]
|
13
11
|
def rename_device(device, name)
|
14
|
-
Executor.execute(
|
12
|
+
Executor.execute(command_for('rename', device.udid, Shellwords.shellescape(name)))
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module SimCtl
|
2
2
|
class Command
|
3
3
|
module Shutdown
|
4
|
-
COMMAND = %w[xcrun simctl shutdown]
|
5
|
-
|
6
4
|
# Shutdown a device
|
7
5
|
#
|
8
6
|
# @param device [SimCtl::Device] the device to shutdown
|
9
7
|
# @return [void]
|
10
8
|
def shutdown_device(device)
|
11
|
-
Executor.execute(
|
9
|
+
Executor.execute(command_for('shutdown', device.udid))
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
data/lib/simctl/device_path.rb
CHANGED
@@ -3,10 +3,17 @@ module SimCtl
|
|
3
3
|
attr_reader :device_plist, :global_preferences_plist, :home, :preferences_plist
|
4
4
|
|
5
5
|
def initialize(udid)
|
6
|
-
@home = File.join(
|
6
|
+
@home = File.join(device_set_path, udid)
|
7
7
|
@device_plist = File.join(@home, 'device.plist')
|
8
8
|
@global_preferences_plist = File.join(@home, 'data/Library/Preferences/.GlobalPreferences.plist')
|
9
9
|
@preferences_plist = File.join(@home, 'data/Library/Preferences/com.apple.Preferences.plist')
|
10
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def device_set_path
|
15
|
+
return SimCtl.device_set_path unless SimCtl.device_set_path.nil?
|
16
|
+
File.join(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices')
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
data/lib/simctl/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class SimCtl::ExecutorTest < Minitest::Test
|
5
|
+
should 'raise exception' do
|
6
|
+
assert_raises { SimCtl::Executor.execute(['xcrun simctl asdf']) }
|
7
|
+
end
|
8
|
+
|
9
|
+
should 'return json' do
|
10
|
+
json = SimCtl::Executor.execute(["echo '{\"foo\":\"bar\"}'"]) do |result|
|
11
|
+
result
|
12
|
+
end
|
13
|
+
assert json == {'foo' => 'bar'}
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'return string' do
|
17
|
+
string = SimCtl::Executor.execute(["echo 'hello world'"]) do |result|
|
18
|
+
result
|
19
|
+
end
|
20
|
+
assert string == 'hello world'
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simctl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Plunien
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -126,9 +126,10 @@ files:
|
|
126
126
|
- test/SampleApp/SampleApp/AppDelegate.m
|
127
127
|
- test/SampleApp/SampleApp/Info.plist
|
128
128
|
- test/SampleApp/SampleApp/main.m
|
129
|
-
- test/simctl/
|
130
|
-
- test/simctl/
|
131
|
-
- test/simctl/
|
129
|
+
- test/simctl/crud_test.rb
|
130
|
+
- test/simctl/executor_test.rb
|
131
|
+
- test/simctl/list_test.rb
|
132
|
+
- test/simctl/readme_test.rb
|
132
133
|
- test/test_helper.rb
|
133
134
|
homepage: https://github.com/plu/simctl
|
134
135
|
licenses:
|
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: '0'
|
151
152
|
requirements: []
|
152
153
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.6.6
|
154
155
|
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: Ruby interface to xcrun simctl
|
@@ -162,7 +163,8 @@ test_files:
|
|
162
163
|
- test/SampleApp/SampleApp/AppDelegate.m
|
163
164
|
- test/SampleApp/SampleApp/Info.plist
|
164
165
|
- test/SampleApp/SampleApp/main.m
|
165
|
-
- test/simctl/
|
166
|
-
- test/simctl/
|
167
|
-
- test/simctl/
|
166
|
+
- test/simctl/crud_test.rb
|
167
|
+
- test/simctl/executor_test.rb
|
168
|
+
- test/simctl/list_test.rb
|
169
|
+
- test/simctl/readme_test.rb
|
168
170
|
- test/test_helper.rb
|