Sha256: d4bf2ab01aa5e09411866c6771dbef9fa9f4db4de349a98c57f1c2ad41432080

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

module SimCtl
  class DevicePath
    def initialize(device)
      @device = device
    end

    def device_plist
      @device_plist ||= File.join(home, 'device.plist')
    end

    def global_preferences_plist
      @global_preferences_plist ||= File.join(home, 'data/Library/Preferences/.GlobalPreferences.plist')
    end

    def home
      @home ||= File.join(device_set_path, device.udid)
    end

    def launchctl
      @launchctl ||= File.join(runtime_root, 'bin/launchctl')
    end

    def preferences_plist
      @preferences_plist ||= File.join(home, 'data/Library/Preferences/com.apple.Preferences.plist')
    end

    private

    attr_reader :device

    def device_set_path
      return SimCtl.device_set_path unless SimCtl.device_set_path.nil?
      File.join(ENV['HOME'], 'Library/Developer/CoreSimulator/Devices')
    end

    def locate_runtime_root
      "/Library/Developer/CoreSimulator/Profiles/Runtimes/#{device.runtime.name}.simruntime/Contents/Resources/RuntimeRoot".tap do |path|
        return path if File.exists?(path)
      end
      Xcode::Path.sdk_root
    end

    def runtime_root
      @runtime_root ||= locate_runtime_root
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simctl-1.6.1 lib/simctl/device_path.rb
simctl-1.6.0 lib/simctl/device_path.rb