simctl 1.3.1 → 1.4.0

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: b6319499832101d1764c51beca6deb17a733bb6e
4
- data.tar.gz: 72e4cce1320238f838cf2402dfeda5982fc23045
3
+ metadata.gz: 720fbd09efb48085401d8eabd6ee2a089117c94e
4
+ data.tar.gz: 1d9c650feb22866a4759b498a782820483682641
5
5
  SHA512:
6
- metadata.gz: e5f94ba9adb2fd3b3973bce68c70a458e04493dfdf7d7f4e5ff2c997adfe18360100b500b3253a1edd7c90cfa437ae2bc13c4baefd6afefb228b07ba256f9e36
7
- data.tar.gz: 865de7a145b2fa34f2aa1e59d5e211bbc7d30f790fd2b8b6ae3fed15e44b0c60b62006d3261b2fa6b2f35f3c787a5fcdd9acde3e61761a01e90d9e140cbc932b
6
+ metadata.gz: 40a6b4665e6d1a5877c0a0e6b583e05137c278c116c5ddacfbbb50e827b51d1307495de34812ee87b27b1089d9583e3e3c9cc5bf922681b334b4147327f70502
7
+ data.tar.gz: 3a59cd1b61cb17b5698b7deb920ca7fdd7d3d80cfa58695eda4c9eb2bfb3890303211d0dfc17fa058198e0c0d9aa17bb144643759f36fdf759f6c9d9ad41ac52
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simctl (1.3.1)
4
+ simctl (1.4.0)
5
5
  CFPropertyList
6
6
 
7
7
  GEM
data/lib/simctl.rb CHANGED
@@ -1,16 +1,27 @@
1
1
  require 'simctl/command'
2
2
  require 'simctl/device'
3
3
  require 'simctl/device_type'
4
+ require 'simctl/helper'
4
5
  require 'simctl/list'
5
6
  require 'simctl/runtime'
6
7
 
7
8
  module SimCtl
8
9
  class << self
10
+ include Helper
11
+
9
12
  def command
10
13
  return @command if defined?(@command)
11
14
  @command = SimCtl::Command.new
12
15
  end
13
16
 
17
+ # Edit `Library/Preferences/com.apple.iphonesimulator.plist`
18
+ #
19
+ # @return [void]
20
+ # @yield [Hash] The hash of the preferences plist. Modifications will be written to the file.
21
+ def edit_iphonesimulator_plist(&block)
22
+ edit_plist(File.join(ENV['HOME'], 'Library/Preferences/com.apple.iphonesimulator.plist'), &block)
23
+ end
24
+
14
25
  private
15
26
 
16
27
  def respond_to_missing?(method_name, include_private=false)
data/lib/simctl/device.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'cfpropertylist'
2
2
  require 'ostruct'
3
3
  require 'simctl/device_path'
4
+ require 'simctl/device_settings'
4
5
  require 'simctl/object'
5
6
  require 'timeout'
6
7
 
@@ -29,25 +30,12 @@ module SimCtl
29
30
  @devicetype ||= SimCtl.devicetype(identifier: plist.deviceType)
30
31
  end
31
32
 
33
+ # <b>DEPRECATED:</b> Please use <tt>device.settings.disable_keyboard_helpers!</tt> instead.
32
34
  # Disables the keyboard helpers
33
35
  #
34
36
  # @return [void]
35
37
  def disable_keyboard_helpers!
36
- path.edit path.preferences_plist do |plist|
37
- %w(
38
- KeyboardPeriodShortcut
39
- KeyboardAutocapitalization
40
- KeyboardCheckSpelling
41
- KeyboardAssistant
42
- KeyboardAutocorrection
43
- KeyboardPrediction
44
- KeyboardShowPredictionBar
45
- KeyboardCapsLock
46
- ).each do |key|
47
- plist[key] = false
48
- end
49
- plist
50
- end
38
+ settings.disable_keyboard_helpers!
51
39
  end
52
40
 
53
41
  # Erases the device
@@ -96,6 +84,13 @@ module SimCtl
96
84
  @runtime ||= SimCtl.runtime(identifier: plist.runtime)
97
85
  end
98
86
 
87
+ # Returns the settings object
88
+ #
89
+ # @ return [SimCtl::DeviceSettings]
90
+ def settings
91
+ @settings ||= DeviceSettings.new(path)
92
+ end
93
+
99
94
  # Shuts down the runtime
100
95
  #
101
96
  # @return [void]
@@ -1,21 +1,12 @@
1
- require 'simctl/object'
2
-
3
1
  module SimCtl
4
2
  class DevicePath
5
- attr_reader :device_plist, :home, :preferences_plist
3
+ attr_reader :device_plist, :global_preferences_plist, :home, :preferences_plist
6
4
 
7
5
  def initialize(udid)
8
6
  @home = File.join(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices', udid)
9
7
  @device_plist = File.join(@home, 'device.plist')
8
+ @global_preferences_plist = File.join(@home, 'data/Library/Preferences/.GlobalPreferences.plist')
10
9
  @preferences_plist = File.join(@home, 'data/Library/Preferences/com.apple.Preferences.plist')
11
10
  end
12
-
13
- def edit(path, &block)
14
- plist = File.exists?(path) ? CFPropertyList::List.new(file: path) : CFPropertyList::List.new
15
- content = CFPropertyList.native_types(plist.value) || {}
16
- plist.value = CFPropertyList.guess(yield content)
17
- plist.save(path, CFPropertyList::List::FORMAT_BINARY)
18
- end
19
-
20
11
  end
21
12
  end
@@ -0,0 +1,45 @@
1
+ require 'simctl/helper'
2
+
3
+ module SimCtl
4
+ class DeviceSettings
5
+ include SimCtl::Helper
6
+
7
+ attr_reader :path
8
+
9
+ def initialize(path)
10
+ @path = path
11
+ end
12
+
13
+ # Disables the keyboard helpers
14
+ #
15
+ # @return [void]
16
+ def disable_keyboard_helpers!
17
+ edit_plist(path.preferences_plist) do |plist|
18
+ %w(
19
+ KeyboardAllowPaddle
20
+ KeyboardAssistant
21
+ KeyboardAutocapitalization
22
+ KeyboardAutocorrection
23
+ KeyboardCapsLock
24
+ KeyboardCheckSpelling
25
+ KeyboardPeriodShortcut
26
+ KeyboardPrediction
27
+ KeyboardShowPredictionBar
28
+ ).each do |key|
29
+ plist[key] = false
30
+ end
31
+ end
32
+ end
33
+
34
+ # Sets the device language
35
+ #
36
+ # @return [void]
37
+ def set_language(language)
38
+ edit_plist(path.global_preferences_plist) do |plist|
39
+ key = 'AppleLanguages'
40
+ plist[key] = [] unless plist.has_key?(key)
41
+ plist[key].unshift(language).uniq!
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,18 @@
1
+ require 'cfpropertylist'
2
+
3
+ module SimCtl
4
+ module Helper
5
+ # Edit some plist
6
+ #
7
+ # @param [String] Path to the plist
8
+ # @return [void]
9
+ # @yield [Hash] The hash of the plist. Modifications will be written to the file.
10
+ def edit_plist(path, &block)
11
+ plist = File.exists?(path) ? CFPropertyList::List.new(file: path) : CFPropertyList::List.new
12
+ content = CFPropertyList.native_types(plist.value) || {}
13
+ yield content
14
+ plist.value = CFPropertyList.guess(content)
15
+ plist.save(path, CFPropertyList::List::FORMAT_BINARY)
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module SimCtl
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -80,7 +80,7 @@ class SimCtl::Command::CRUDTest < Minitest::Test
80
80
 
81
81
  should '12. disable keyboard helpers' do
82
82
  device = SimCtl.device(udid: udid)
83
- device.disable_keyboard_helpers!
83
+ device.settings.disable_keyboard_helpers!
84
84
  assert File.exists?(device.path.preferences_plist)
85
85
  end
86
86
 
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.3.1
4
+ version: 1.4.0
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-03-30 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -109,8 +109,10 @@ files:
109
109
  - lib/simctl/command/shutdown.rb
110
110
  - lib/simctl/device.rb
111
111
  - lib/simctl/device_path.rb
112
+ - lib/simctl/device_settings.rb
112
113
  - lib/simctl/device_type.rb
113
114
  - lib/simctl/executor.rb
115
+ - lib/simctl/helper.rb
114
116
  - lib/simctl/list.rb
115
117
  - lib/simctl/object.rb
116
118
  - lib/simctl/runtime.rb