apple_sim_utils 0.1.1 → 0.1.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: 955b74a3847528b5b2c2cfc251dcd205a57e4f02
4
- data.tar.gz: bd76986e89e5b760ad6206cd384ca56d11511bad
3
+ metadata.gz: 5267b96c0e69fc77d0d8c33e71e5e55c18364569
4
+ data.tar.gz: 94b82dcfdf6a2a348709a0f73707f64d7c792909
5
5
  SHA512:
6
- metadata.gz: 745086bb894f57f49d5834446ec2b0a969291644fb8e49a3e74e4c98e1d07ebd39d17c0736edb02bd282e407df00283253ce17053c1c5670971e3fa577be4ca6
7
- data.tar.gz: c5b2e072fc6151d09813e74d7d39fe29338d494f60666bfef07d2bc61b44bb1814bb5bb4cf88b0f022a2caca2feb5e6436b719b45558e8eb4f9e23bef927d43d
6
+ metadata.gz: f3e88ccc4efeec86111454d4b30dd11314e1d2d0ccd391253a4d6432a0018e67ec8a2153150e3f0054fe97fdc139b25d800df8f107b14ada9e192fd8546d7167
7
+ data.tar.gz: 93fa18e04ee3f54db936e853aba6cb32d3428ef8ad03f2ae74aeabe625159b443c681fdbae7eaeb42e1b2d49c6ac6410cfad942d36d2626b1aced753799a1a58
data/README.md CHANGED
@@ -20,7 +20,12 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ ```
24
+ $ cmd = AppleSimUtils::Cmd.new(bundle_id: 'com.apple.example')
25
+ $ cmd.allow_all(device: 'iPhone SE, OS = 10.3', permissions: %w(notifications photos camera))
26
+ ```
27
+
28
+ See test/apple_sim_utils_test.rb for more details.
24
29
 
25
30
  ## Development
26
31
 
@@ -30,7 +35,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
30
35
 
31
36
  ## Contributing
32
37
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/Kazuaki MATSUO/apple_sim_utils.
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/KazuCocoa/apple_sim_utils.
34
39
 
35
40
 
36
41
  ## License
@@ -1,13 +1,38 @@
1
1
  module AppleSimUtils
2
2
  class Cmd
3
- attr_reader :path
3
+ attr_reader :path, :bundle_id
4
4
 
5
- def initialize
5
+ def initialize(bundle_id: nil)
6
6
  @path = get_command_path
7
+ @bundle_id = bundle_id
8
+ end
9
+
10
+ def allow_all(device:, permissions:)
11
+ raise 'You should set bundle_id' if @bundle_id.nil?
12
+
13
+ p = permissions.map {|permission| permission + '=YES'}.join(',')
14
+ run(%(--simulator '#{device}' --bundle #{@bundle_id} --setPermissions '#{p}'))
15
+ end
16
+
17
+ def deny_all(device:, permissions:)
18
+ raise 'You should set bundle_id' if @bundle_id.nil?
19
+
20
+ p = permissions.map {|permission| permission + '=NO'}.join(',')
21
+ run(%(--simulator '#{device}' --bundle #{@bundle_id} --setPermissions '#{p}'))
22
+ end
23
+
24
+ def set(device:, permission:, value:)
25
+ run(%(--simulator '#{device}' --bundle #{@bundle_id} --setPermissions '#{permission}=#{value}'))
26
+ end
27
+
28
+ def restart(device:)
29
+ run(%(--simulator '#{device}' --restartSB))
7
30
  end
8
31
 
9
32
  def run(*command)
33
+ return command.join(' ') if ENV['DRY_RUN']
10
34
  cmd = ([@path] + command).join(' ')
35
+
11
36
  sto, ste, status = Open3.capture3(cmd)
12
37
  if status.success?
13
38
  unless ste.empty?
@@ -26,7 +51,7 @@ module AppleSimUtils
26
51
  def get_command_path
27
52
  cmd = `which applesimutils`.strip
28
53
  return cmd unless cmd.empty?
29
- raise "You should install applesimutils. Read https://github.com/wix/AppleSimulatorUtils"
54
+ raise 'You should install applesimutils. Read https://github.com/wix/AppleSimulatorUtils'
30
55
  end
31
56
  end
32
57
  end
@@ -1,3 +1,3 @@
1
1
  module AppleSimUtils
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_sim_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-03 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler