#RUBY-17510 support of github RailsApp Samples in RubyMine and IDEA

This commit is contained in:
Dmitry.Krasilschikov
2016-01-25 19:51:43 +03:00
parent 5887777e29
commit c09d1c1cfb
@@ -21,6 +21,7 @@ import java.util.concurrent.Callable;
* @author Sergey Simonchik
*/
public class GithubDownloadUtil {
private static final String PROJECT_GENERATORS = "projectGenerators";
private GithubDownloadUtil() {}
@@ -29,9 +30,14 @@ public class GithubDownloadUtil {
return "github-" + userName + "-" + repositoryName;
}
@NotNull
private static String formatGithubUserName(@NotNull String userName) {
return "github-" + userName;
}
@NotNull
public static File getCacheDir(@NotNull String userName, @NotNull String repositoryName) {
File generatorsDir = new File(PathManager.getSystemPath(), "projectGenerators");
File generatorsDir = new File(PathManager.getSystemPath(), PROJECT_GENERATORS);
String dirName = formatGithubRepositoryName(userName, repositoryName);
File dir = new File(generatorsDir, dirName);
try {
@@ -41,6 +47,18 @@ public class GithubDownloadUtil {
}
}
@NotNull
public static File getUserCacheDir(@NotNull String userName) {
File generatorsDir = new File(PathManager.getSystemPath(), PROJECT_GENERATORS);
String dirName = formatGithubUserName(userName);
File dir = new File(generatorsDir, dirName);
try {
return dir.getCanonicalFile();
} catch (IOException e) {
return dir;
}
}
public static File findCacheFile(@NotNull String userName, @NotNull String repositoryName, @NotNull String cacheFileName) {
File dir = getCacheDir(userName, repositoryName);
return new File(dir, cacheFileName);