Class: Bwoken::Simulator

Inherits:
Object
  • Object
show all
Defined in:
lib/bwoken/simulator.rb

Class Method Summary collapse

Class Method Details

.device_family=(device_family) ⇒ Object



7
8
9
10
11
# File 'lib/bwoken/simulator.rb', line 7

def self.device_family= device_family
  update_device_family_in_plist :delete_array
  update_device_family_in_plist :add_array
  update_device_family_in_plist :add_scalar, device_family
end

.plist_buddyObject



4
# File 'lib/bwoken/simulator.rb', line 4

def self.plist_buddy; '/usr/libexec/PlistBuddy'; end

.plist_fileObject



5
# File 'lib/bwoken/simulator.rb', line 5

def self.plist_file; "#{Bwoken::Build.new.app_dir}/Info.plist"; end

.update_device_family_in_plist(action, args = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bwoken/simulator.rb', line 13

def self.update_device_family_in_plist action, args = nil
  system_cmd = lambda {|command| Kernel.system "#{plist_buddy} -c '#{command}' #{plist_file}" }

  case action
  when :delete_array then system_cmd['Delete :UIDeviceFamily']
  when :add_array    then system_cmd['Add :UIDeviceFamily array']
  when :add_scalar
    command = lambda {|scalar| "Add :UIDeviceFamily:0 integer #{scalar == 'iphone' ? 1 : 2}"}

    case args
    when /iphone/i
      system_cmd[command['iphone']]
    when /ipad/i
      system_cmd[command['ipad']]
    when /universal/i
      system_cmd[command['ipad']]
      system_cmd[command['iphone']]
    end

  end
end