simctl 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b69dda3a4d2d65b36411424b2348d7fe2e7bc6e3
4
- data.tar.gz: c6628e187a8ebb0b7daee3abeaa524154623f60e
3
+ metadata.gz: 1fe7b798df933dcbdfdd2846945ca54fcadc5464
4
+ data.tar.gz: 6f37177c83e58a6b2ee88761645a324a15a0aab8
5
5
  SHA512:
6
- metadata.gz: 4a5b354223c05fbfa7170412de2e570a785b0ba6e4c06320da678ae45b5b6a01ba90303d055a05078263c0284d80da3910c20898f4520383fa1f0d8efcb06e93
7
- data.tar.gz: 3b22417301bb749c1935f686d97d6827a452ec3cce88e13c7f2f2aca8d9a1a3d8a388e766d10f8a108a8087e7a88deeddd0d7b2001e63571fa56eb1d95f24078
6
+ metadata.gz: 6988d3709f1ceeb1012862d812e86cb4003d280193eba5e2a635d797220c6a7385112adb30c3d9a5c8a27a1629d8239632f12023d6ffbf5c2555c2e40edffdfb
7
+ data.tar.gz: 0cb73e083361d8a5aad520a36a931ce489f08178900716926f5f6348a57c900c5a8d49d6ffa69db70a6b047f7c458c2ed7c366c49cec35f0b6c1cb840abde35f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simctl (1.0.0)
4
+ simctl (1.0.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,6 +2,8 @@ require 'simctl/command/boot'
2
2
  require 'simctl/command/create'
3
3
  require 'simctl/command/delete'
4
4
  require 'simctl/command/erase'
5
+ require 'simctl/command/kill'
6
+ require 'simctl/command/launch'
5
7
  require 'simctl/command/list'
6
8
  require 'simctl/command/shutdown'
7
9
  require 'simctl/executor'
@@ -12,6 +14,8 @@ module SimCtl
12
14
  include SimCtl::Command::Create
13
15
  include SimCtl::Command::Delete
14
16
  include SimCtl::Command::Erase
17
+ include SimCtl::Command::Kill
18
+ include SimCtl::Command::Launch
15
19
  include SimCtl::Command::List
16
20
  include SimCtl::Command::Shutdown
17
21
  end
@@ -24,7 +24,7 @@ module SimCtl
24
24
  # @yield [exception] an exception that might happen during shutdown/delete of the old device
25
25
  def reset_device(name, device_type, runtime)
26
26
  begin
27
- SimCtl.list_devices.where(name: name, os: runtime.name).each do |device|
27
+ list_devices.where(name: name, os: runtime.name).each do |device|
28
28
  device.shutdown! if device.state != 'Shutdown'
29
29
  device.delete!
30
30
  end
@@ -0,0 +1,18 @@
1
+ module SimCtl
2
+ class Command
3
+ module Kill
4
+ # Kills a Simulator instance with the given device
5
+ #
6
+ # @param device [SimCtl::Device] the device to kill
7
+ # @return [void]
8
+ def kill_device(device)
9
+ pid = `ps xww | grep Simulator.app | grep -s #{device.udid} | grep -v grep | awk '{print $1}'`.chomp
10
+ if pid.to_i > 0
11
+ system 'kill', pid
12
+ else
13
+ false
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module SimCtl
2
+ class Command
3
+ module Launch
4
+ XCODE_HOME = `xcode-select -p`.chomp
5
+
6
+ # Launches a Simulator instance with the given device
7
+ #
8
+ # @param device [SimCtl::Device] the device to launch
9
+ # @return [void]
10
+ def launch_device(device)
11
+ # Launching the same device twice does not work.
12
+ # Simulator.app would just hang. Solution: Kill first.
13
+ kill_device(device)
14
+ command = "open -n #{XCODE_HOME}/Applications/Simulator.app --args -ConnectHardwareKeyboard 0 -CurrentDeviceUDID #{device.udid}"
15
+ system command
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/simctl/device.rb CHANGED
@@ -19,6 +19,14 @@ module SimCtl
19
19
  SimCtl.erase_device(self)
20
20
  end
21
21
 
22
+ def kill!
23
+ SimCtl.kill_device(self)
24
+ end
25
+
26
+ def launch!
27
+ SimCtl.launch_device(self)
28
+ end
29
+
22
30
  # Shutdown the device
23
31
  def shutdown!
24
32
  SimCtl.shutdown_device(self)
@@ -1,3 +1,3 @@
1
1
  module SimCtl
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  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.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Plunien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-27 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -87,6 +87,8 @@ files:
87
87
  - lib/simctl/command/create.rb
88
88
  - lib/simctl/command/delete.rb
89
89
  - lib/simctl/command/erase.rb
90
+ - lib/simctl/command/kill.rb
91
+ - lib/simctl/command/launch.rb
90
92
  - lib/simctl/command/list.rb
91
93
  - lib/simctl/command/shutdown.rb
92
94
  - lib/simctl/device.rb
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  version: '0'
121
123
  requirements: []
122
124
  rubyforge_project:
123
- rubygems_version: 2.2.2
125
+ rubygems_version: 2.5.2
124
126
  signing_key:
125
127
  specification_version: 4
126
128
  summary: Ruby interface to xcrun simctl