Class: AppleSimUtils::Cmd
- Inherits:
-
Object
- Object
- AppleSimUtils::Cmd
- Defined in:
- lib/apple_sim_utils/command.rb
Instance Attribute Summary collapse
-
#bundle_id ⇒ Object
readonly
Returns the value of attribute bundle_id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #allow_all(device:, permissions:) ⇒ Object
- #deny_all(device:, permissions:) ⇒ Object
-
#initialize(bundle_id: nil) ⇒ Cmd
constructor
A new instance of Cmd.
- #restart(device:) ⇒ Object
- #run(*command) ⇒ Object
- #set(device:, permission:, value:) ⇒ Object
Constructor Details
#initialize(bundle_id: nil) ⇒ Cmd
Returns a new instance of Cmd.
5 6 7 8 |
# File 'lib/apple_sim_utils/command.rb', line 5 def initialize(bundle_id: nil) @path = get_command_path @bundle_id = bundle_id end |
Instance Attribute Details
#bundle_id ⇒ Object (readonly)
Returns the value of attribute bundle_id.
3 4 5 |
# File 'lib/apple_sim_utils/command.rb', line 3 def bundle_id @bundle_id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/apple_sim_utils/command.rb', line 3 def path @path end |
Instance Method Details
#allow_all(device:, permissions:) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/apple_sim_utils/command.rb', line 10 def allow_all(device:, permissions:) raise 'You should set bundle_id' if @bundle_id.nil? p = .map {|| + '=YES'}.join(',') run(%(--simulator '#{device}' --bundle #{@bundle_id} --setPermissions '#{p}')) end |
#deny_all(device:, permissions:) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/apple_sim_utils/command.rb', line 17 def deny_all(device:, permissions:) raise 'You should set bundle_id' if @bundle_id.nil? p = .map {|| + '=NO'}.join(',') run(%(--simulator '#{device}' --bundle #{@bundle_id} --setPermissions '#{p}')) end |
#restart(device:) ⇒ Object
28 29 30 |
# File 'lib/apple_sim_utils/command.rb', line 28 def restart(device:) run(%(--simulator '#{device}' --restartSB)) end |
#run(*command) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/apple_sim_utils/command.rb', line 32 def run(*command) return command.join(' ') if ENV['DRY_RUN'] cmd = ([@path] + command).join(' ') sto, ste, status = Open3.capture3(cmd) if status.success? unless ste.empty? puts ste return ste end sto else puts ste raise(sto) end end |
#set(device:, permission:, value:) ⇒ Object
24 25 26 |
# File 'lib/apple_sim_utils/command.rb', line 24 def set(device:, permission:, value:) run(%(--simulator '#{device}' --bundle #{@bundle_id} --setPermissions '#{}=#{value}')) end |