public static File getWindowsInterpreterExecutableFile()

in rake-runner-test/src/jetbrains/slow/plugins/rakerunner/RakeRunnerTestUtil.java [120:146]


  public static File getWindowsInterpreterExecutableFile(@NotNull final String prefix) throws InterpreterNotFoundException {
    String interpretersStoragePath = System.getProperty(INTERPRETERS_STORAGE_PATH_PROPERTY);
    if (StringUtil.isEmptyOrSpaces(interpretersStoragePath)) {
      throw new InterpreterNotFoundException("Cannot found interpreters storage location. Please specify \"" +
                                             INTERPRETERS_STORAGE_PATH_PROPERTY + "\" property as path to interpreters storage");
    }

    File storageDir = new File(interpretersStoragePath);
    final File[] acceptablePaths = storageDir.listFiles(new FileFilter() {
      public boolean accept(@NotNull final File pathname) {
        return pathname.isDirectory() && pathname.getName().startsWith(prefix);
      }
    });
    System.out.println("interpretersStoragePath = " + interpretersStoragePath);
    if (acceptablePaths == null || acceptablePaths.length == 0) {
      throw new InterpreterNotFoundException("Cannot found any interpreter path with prefix \"" + prefix + "\"");
    }
    if (acceptablePaths.length != 1) {
      throw new InterpreterNotFoundException(
        "There more than one interpreter path with prefix \"" + prefix + "\", founded " + acceptablePaths.length + " path");
    }
    File interpreter = new File(acceptablePaths[0], "/bin/" + (prefix.startsWith("jruby") ? "jruby.bat" : "ruby.exe"));
    if (!interpreter.exists() || !interpreter.isFile()) {
      throw new InterpreterNotFoundException("Founded path is not exist \"" + interpreter.getAbsolutePath() + "\"");
    }
    return interpreter;
  }