public static boolean sdkRefMatchesManual()

in rake-runner-agent/src/org/jetbrains/plugins/ruby/rvm/SharedRVMUtil.java [100:133]


  public static boolean sdkRefMatchesManual(@NotNull final String sdkRef,
                                            @NotNull final String distName) {
    // starts with
    // e.g. [ruby-1.8.7] and [ruby-1.8.7-p249, ruby-1.8.7, ruby-1.8.7-2010.01]
    // TODO [romeo]: rvm use jruby will chose jruby with highest version!
    if (distName.startsWith(sdkRef)) {
      return true;
    }

    // Starts with number
    if (Character.digit(sdkRef.charAt(0), 10) != -1) {
      if (VersionComparatorUtil.compare(sdkRef, "1.8") >= 0) {
        // Looks like ruby
        if (distName.startsWith("ruby-" + sdkRef)) {
          return true;
        }
      } else {
        // Looks like jruby
        if (distName.startsWith("jruby-" + sdkRef)) {
          return true;
        }
      }
    }

    // Ignore patchversion (match ruby-2.1.0-p0 to ruby-2.1.0)
    final Matcher matcher = Pattern.compile("(.*)\\-p([0-9]+)").matcher(sdkRef);
    if (matcher.matches()) {
      // sdkRef have patchversion
      final String ref = matcher.group(1);
      return sdkRefMatchesManual(ref, distName);
    }

    return false;
  }