<commit_before>package com.dhemery.victor.discovery;

import com.dhemery.configuration.ContextItemCache;

/**
 * Represents an iOS SDK.
 */
public class IosSdk {
    public static final String GENERIC_SDK_NAME = "iphonesimulator";
    public static final String NAME_FOR_SDK_VERSION = GENERIC_SDK_NAME + "%s";
    public static final String PLATFORM_PATH = "PlatformPath";
    public static final String SDK_PATH = "Path";
    public static final String SDK_VERSION = "SDKVersion";
    public static final String SIMULATOR_BINARY_PATH_FOR_PLATFORM = "%s/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator";
    private static final ContextItemCache sdkInfo = new SdkInfoCache();
    protected final String canonicalName;

    public IosSdk(String canonicalName) {
        this.canonicalName = canonicalName;
    }

    /**
     * @return a representation of the newest installed SDK.
     */
    public static IosSdk newest() {
        return withCanonicalName(GENERIC_SDK_NAME);
    }

    /**
     * @param canonicalName the canonical name of an SDK.
     * @return a representation of the SDK with that canonical name.
     */
    public static IosSdk withCanonicalName(String canonicalName) {
        return new IosSdk(canonicalName);
    }

    /**
     * @param version the version of an SDK.
     * @return a representation of the SDK with that version.
     */
    public static IosSdk withVersion(String version) {
        return withCanonicalName(String.format(NAME_FOR_SDK_VERSION, version));
    }

    public String canonicalName() {
        return canonicalName;
    }

    public boolean isInstalled() {
        return path().startsWith("/");
    }

    public String sdkInfo(String itemName) {
        return sdkInfo(canonicalName, itemName);
    }

    public String path(){
        return sdkInfo(SDK_PATH);
    }

    public String version() {
        return sdkInfo(SDK_VERSION);
    }

    /**
     * @return the absolute path to the iPhone Simulator platform on this computer.
     */
    public static String platformPath() {
        return sdkInfo(GENERIC_SDK_NAME, PLATFORM_PATH);
    }

    private static String sdkInfo(String canonicalName, String itemName) {<commit_msg>Fix how Victor discovers whether an SDK version is installed<commit_after>package com.dhemery.victor.discovery;

import com.dhemery.configuration.ContextItemCache;

/**
 * Represents an iOS SDK.
 */
public class IosSdk {
    public static final String GENERIC_SDK_NAME = "iphonesimulator";
    public static final String NAME_FOR_SDK_VERSION = GENERIC_SDK_NAME + "%s";
    public static final String PLATFORM_PATH = "PlatformPath";
    public static final String SDK_PATH = "Path";
    public static final String SDK_VERSION = "SDKVersion";
    public static final String SIMULATOR_BINARY_PATH_FOR_PLATFORM = "%s/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator";
    private static final ContextItemCache sdkInfo = new SdkInfoCache();
    protected final String canonicalName;

    public IosSdk(String canonicalName) {
        this.canonicalName = canonicalName;
    }

    /**
     * @return a representation of the newest installed SDK.
     */
    public static IosSdk newest() {
        return withCanonicalName(GENERIC_SDK_NAME);
    }

    /**
     * @param canonicalName the canonical name of an SDK.
     * @return a representation of the SDK with that canonical name.
     */
    public static IosSdk withCanonicalName(String canonicalName) {
        return new IosSdk(canonicalName);
    }

    /**
     * @param version the version of an SDK.
     * @return a representation of the SDK with that version.
     */
    public static IosSdk withVersion(String version) {
        return withCanonicalName(String.format(NAME_FOR_SDK_VERSION, version));
    }

    public String canonicalName() {
        return canonicalName;
    }

    public boolean isInstalled() {
        return path() != null;
    }

    public String sdkInfo(String itemName) {
        return sdkInfo(canonicalName, itemName);
    }

    public String path(){
        return sdkInfo(SDK_PATH);
    }

    public String version() {
        return sdkInfo(SDK_VERSION);
    }

    /**
     * @return the absolute path to the iPhone Simulator platform on this computer.
     */
    public static String platformPath() {
        return sdkInfo(GENERIC_SDK_NAME, PLATFORM_PATH);
    }

    private static String sdkInfo(String canonicalName, String itemName) {
{'fraction_non_alphanumeric': 0.07934031646980165, 'fraction_numerical': 0.0, 'mean_word_length': 3.1174311926605505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4225908', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1223, 'n_words': 376}