Class: SimctlParser

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

Instance Method Summary collapse

Instance Method Details

#get_devicesObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/simctl_parser.rb', line 2

def get_devices
  output = `xcrun simctl list`.strip
  output = output.split("== Devices ==").last
  os = ""
  output.lines.map do |line|
    if line.strip.start_with?( "--")
      os = line.gsub("-","").strip
    end
    
    if line.strip.length != 0 && line.strip.start_with?( "--") == false
    {
      :name => line.strip.split(" ")[0..-3].join(" "),
      :state => line.strip.split(" ")[-1],
      :id => line.strip.split(" ")[-2][1..-2].strip,
      :os => os
    }
    end
  end.compact
end

#open_deviceObject



22
23
24
25
26
# File 'lib/simctl_parser.rb', line 22

def open_device
  get_devices.select do | device |
    device[:state] == "(Booted)"
  end.first
end