lib/fourflusher/find.rb
# Gets the simulators and transforms the simctl json into Simulator objects
Gets the simulators and transforms the simctl json into Simulator objects
Gets the simulators and transforms the simctl json into Simulator objects
def fetch_sims
      raw_list = list(['-j', 'devices'])
      regex_union = Regexp.union(LINES_TO_REMOVE)
      filtered_raw_list = raw_list.each_line.reject { |l| l =~ regex_union }.join
      device_list = JSON.parse(filtered_raw_list)['devices']
      unless device_list.is_a?(Hash)
        msg = "Expected devices to be of type Hash but instated found #{device_list.class}"
        fail Fourflusher::Informative, msg
      end
      device_list.flat_map do |runtime_str, devices|
        if runtime_str.start_with?('com.apple.CoreSimulator.SimRuntime.')
          _unused, os_info = runtime_str.split 'com.apple.CoreSimulator.SimRuntime.'
          os_name, os_major_version, os_minor_version = os_info.split '-'
          os_version = "#{os_major_version}.#{os_minor_version}"
        else
          os_name, os_version = runtime_str.split ' '
        end
        devices.map do |device|
          device_is_available = device['isAvailable'] == 'YES' || device['isAvailable'] == true
          if device['availability'] == '(available)' || device_is_available
            Simulator.new(device, os_name, os_version)
          end
        end
      end.compact.sort(&:sim_list_compare)
    end
def fetch_sims raw_list = list ( [ '-j' , 'devices' ] ) regex_union = Regexp . union ( LINES_TO_REMOVE ) filtered_raw_list = raw_list . each_line . reject { | l | l =~ regex_union } . join device_list = JSON . parse ( filtered_raw_list ) [ 'devices' ] unless device_list . is_a? ( Hash ) msg = "Expected devices to be of type Hash but instated found #{device_list.class}" fail Fourflusher :: Informative , msg end device_list . flat_map do | runtime_str , devices | if runtime_str . start_with? ( 'com.apple.CoreSimulator.SimRuntime.' ) _unused , os_info = runtime_str . split 'com.apple.CoreSimulator.SimRuntime.' os_name , os_major_version , os_minor_version = os_info . split '-' os_version = "#{os_major_version}.#{os_minor_version}" else os_name , os_version = runtime_str . split ' ' end devices . map do | device | device_is_available = device [ 'isAvailable' ] == 'YES' || device [ 'isAvailable' ] == true if device [ 'availability' ] == '(available)' || device_is_available Simulator . new ( device , os_name , os_version ) end end end . compact . sort ( & :sim_list_compare ) end
Gets the simulators and transforms the simctl json into Simulator objects
Gets the simulators and transforms the simctl json into Simulator objects
# This format changed with Xcode 10.2. # Sample string: com.apple.CoreSimulator.SimRuntime.iOS-12-2 # Sample string: iOS 9.3