Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Fixed code style
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Dec 11, 2015
1 parent 9d7de7e commit 4137c24
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/snapshot/reset_simulators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.clear_everything!(ios_versions)
sure = agree("Are you sure? All your simulators will be DELETED and new ones will be created! (y/n)".red, true) unless sure
raise "User cancelled action" unless sure

get_devices.each do |device|
devices.each do |device|
_, name, id = device
puts "Removing device #{name} (#{id})"
`xcrun simctl delete #{id}`
Expand All @@ -35,8 +35,9 @@ def self.clear_everything!(ios_versions)
end
end

phones, watches = [], []
get_devices.each do |device|
phones = []
watches = []
devices.each do |device|
_, name, id = device
phones << id if name.start_with?('iPhone 6')
watches << id if name.end_with?('mm')
Expand All @@ -46,8 +47,6 @@ def self.clear_everything!(ios_versions)
`xcrun simctl pair #{watches.last} #{phones.last}`
end

private

def self.create(device_type, os_versions, os_name = 'iOS')
os_versions.each do |os_version|
puts "Creating #{device_type} for #{os_name} version #{os_version}"
Expand All @@ -56,10 +55,10 @@ def self.create(device_type, os_versions, os_name = 'iOS')
end

def self.filter_runtimes(all_runtimes, os = 'iOS')
all_runtimes.select{ |r| r[/^#{os}/] }.map { |r| r.split(' ')[1] }
all_runtimes.select { |r| r[/^#{os}/] }.map { |r| r.split(' ')[1] }
end

def self.get_devices()
def self.devices
all_devices = `xcrun simctl list devices`
# == Devices ==
# -- iOS 9.0 --
Expand All @@ -69,9 +68,11 @@ def self.get_devices()
# -- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-8-4 --
# iPhone 4s (FE9D6F85-1C51-4FE6-8597-FCAB5286B869) (Shutdown) (unavailable, runtime profile not found)

all_devices.lines.map do |line|
result = all_devices.lines.map do |line|
(line.match(/\s+([\w\s]+)\s\(([\w\-]+)\)/) || []).to_a
end.select { |parsed| parsed.length == 3 } # we don't care about those headers
end

result.select { |parsed| parsed.length == 3 } # we don't care about those headers
end
end
end

0 comments on commit 4137c24

Please sign in to comment.