simctl 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da76a9f1cad014fffee2818138f5e11fbd0cc97e
4
- data.tar.gz: 3932e4c59a417d56f38a69af7f0dd5c16bc12e15
3
+ metadata.gz: f923baf8dbf6166ce07d1890414262712aa65756
4
+ data.tar.gz: ce8194686b27910c708edd304b0ce55366c0c577
5
5
  SHA512:
6
- metadata.gz: ee307c69171853a9d164756c7d842169e33df54a017264bbbc2c9a17fb7c4a5a372d86d9922b989e4333c30224906dbc9050edcce11a04f9a3aad83e5c713a7b
7
- data.tar.gz: 5abd74d5dd1214848a0c0023774c3fa434897d3c3b80660a60876848b39644749ca7b00052f3ad29558af8b7d2bda12bbf1b405c2427deb5f82a95a2ebaa821b
6
+ metadata.gz: 7b20bc6edfabde97837da052ae1d2b951724039111e1493b71eec2f17664155747a854a7053e8a49f4dfef9cce4d49a1ad46e206abfb47c21f95ac0270d64582
7
+ data.tar.gz: 947909872a6e4b6bb082f43699362c19021ca1d072fc5abb7fa85db1f5f1097e90420426bdb26706e33a7a60e84150e6cc5ca04cc18a25fee804c68b0c37674b
@@ -3,5 +3,8 @@ osx_image: xcode7.3
3
3
  before_script:
4
4
  - export LANG=en_US.UTF-8
5
5
  install: bundle
6
+ env:
7
+ - CUSTOM_DEVICE_SET_PATH=true
8
+ - CUSTOM_DEVICE_SET_PATH=false
6
9
  script:
7
10
  - bundle exec rake
@@ -1,3 +1,7 @@
1
+ # 1.5.2
2
+
3
+ * Support custom device set path
4
+
1
5
  # 1.5.1
2
6
 
3
7
  * Let `SimCtl#create_device` wait for the device to be created
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simctl (1.5.1)
4
+ simctl (1.5.2)
5
5
  CFPropertyList
6
6
 
7
7
  GEM
@@ -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
@@ -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([COMMAND, device.udid])
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([COMMAND, Shellwords.shellescape(name), devicetype.identifier, runtime.identifier]) do |identifier|
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([COMMAND, device.udid])
9
+ Executor.execute(command_for('delete', device.udid))
12
10
  end
13
11
 
14
12
  # Delete all devices
@@ -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([COMMAND, device.udid])
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([COMMAND, device.udid, Shellwords.shellescape(path)])
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
- }.merge(opts).zip.flatten.join(' ')
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([LAUNCH_APP_COMMAND, launch_opts, device.udid, identifier, launch_args])
40
+ Executor.execute(command_for('launch', launch_opts, device.udid, identifier, launch_args))
39
41
  end
40
42
  end
41
43
  end
@@ -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([COMMAND, 'devices']) do |json|
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([COMMAND, 'devicetypes']) do |json|
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([COMMAND, 'runtimes']) do |json|
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([COMMAND, device.udid, Shellwords.shellescape(name)])
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([COMMAND, device.udid])
9
+ Executor.execute(command_for('shutdown', device.udid))
12
10
  end
13
11
  end
14
12
  end
@@ -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(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices', udid)
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
@@ -1,3 +1,3 @@
1
1
  module SimCtl
2
- VERSION = '1.5.1'
2
+ VERSION = '1.5.2'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'securerandom'
2
2
  require 'test_helper'
3
3
 
4
- class SimCtl::Command::CRUDTest < Minitest::Test
4
+ class SimCtl::CRUDTest < Minitest::Test
5
5
  order_dependent!
6
6
 
7
7
  udid = nil
@@ -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
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class SimCtl::Command::ListTest < Minitest::Test
3
+ class SimCtl::ListTest < Minitest::Test
4
4
  context 'devicetype' do
5
5
  should 'find device type by name' do
6
6
  assert_kind_of SimCtl::DeviceType, SimCtl.devicetype(name: 'iPhone 5')
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class SimCtl::Command::ReadmeTest < Minitest::Test
3
+ class SimCtl::ReadmeTest < Minitest::Test
4
4
  should 'execute example code from readme' do
5
5
  # Select the iOS 9.2 runtime
6
6
  runtime = SimCtl.runtime(name: 'iOS 9.2')
@@ -10,3 +10,7 @@ require File.dirname(__FILE__) + '/../lib/simctl.rb'
10
10
  if ENV['TRAVIS']
11
11
  SimCtl.default_timeout = 300
12
12
  end
13
+
14
+ unless ENV['CUSTOM_DEVICE_SET_PATH'] == 'false'
15
+ SimCtl.device_set_path = Dir.mktmpdir
16
+ end
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.1
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-07-13 00:00:00.000000000 Z
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/command/crud_test.rb
130
- - test/simctl/command/list_test.rb
131
- - test/simctl/command/readme_test.rb
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.5.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/command/crud_test.rb
166
- - test/simctl/command/list_test.rb
167
- - test/simctl/command/readme_test.rb
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