private static String getGemHomeURL(RubyPlatform platform) { return platform.hasRubyGemsInstalled() ? platform.getGemManager().getGemHomeUrl() : null; }
private void reloadGems() { GemManager gemManager = RubyPlatform.gemManagerFor(this); if (gemManager != null) { gemManager.reloadLocalGems(false); } }
public void editConfig(RailsProject project) { RubyPlatform platform = RubyPlatform.platformFor(project); if (platform.isJRuby()) { // as of 1.1 RC2 JRuby apparently supports socket, but commenting it // out still using 127.0.0.1 rather than localhost for the reasons // described in issue #131024 RailsAdapters.commentOutSocket(project.getProjectDirectory(), "127.0.0.1"); //NOI18N } }
public static boolean isInstalled(final Project project, TestRunner.TestType type) { RubyPlatform platform = RubyPlatform.platformFor(project); if (platform == null) { return false; } if (type == TestRunner.TestType.AUTOTEST) { return platform.hasValidAutoTest(false); } else if (type == TestRunner.TestType.AUTOSPEC) { return platform.hasValidAutoSpec(false); } return false; }
/** * @return whether everything needed for fast debugging is installed */ public boolean hasFastDebuggerInstalled() { // no usable version of Fast Debugger for Rubinius is available yet return getGemManager() != null && !isRubinius() && getFastDebuggerProblemsInHTML() == null; }
public synchronized String getIRB() { if (irb == null) { irb = findExecutable(isJRuby() ? "jirb" : "irb", false, true); // NOI18N } return irb; }
lastSelectedPlatformID = plaf.getID(); plfNameValue.setText(plaf.getInfo().getLongDescription()); plfInterpreterValue.setText(plaf.getInterpreter()); Color color; boolean gemsInstalled = plaf.hasRubyGemsInstalled(); if (gemsInstalled) { gemHomeValue.setText(plaf.getGemManager().getGemHome()); gemPathList.setModel(createGemPathsModel(plaf)); refreshGemToolVersion(); gemToolValue.setText(plaf.getGemTool() + " (" + plaf.getInfo().getGemVersion() + ')'); // NOI18N color = UIManager.getColor("Label.foreground"); } else {
boolean canonical = true; // default do { String binDir = getBinDir(); if (binDir != null) { LOGGER.log(Level.FINER, "Looking for '{0}' executable; used intepreter: '{1}'", new String[]{toFind, getInterpreter()}); // NOI18N exec = RubyPlatform.findExecutable(binDir, toFind); } else { LOGGER.log(Level.WARNING, "Could not find Ruby interpreter executable when searching for '{0}'", toFind); // NOI18N if (exec == null && searchInRubyGems && hasRubyGemsInstalled()) { for (File repo : getGemManager().getRepositories()) { String libGemBinDir = repo.getAbsolutePath() + File.separator + "bin"; // NOI18N exec = RubyPlatform.findExecutable(libGemBinDir, toFind); if (exec != null) { break; exec = findExecutable(toFind + ".bat", searchInRubyGems); // NOI18N
public static void adjustEnvironment(final RubyPlatform platform, final Map<String, String> env) { if (platform.hasRubyGemsInstalled()) { String gemHome = adjustGemPath(platform.getGemManager().getGemHome()); String gemPath = adjustGemPath(platform.getInfo().getGemPath()); env.put("GEM_HOME", gemHome); // NOI18N env.put("GEM_PATH", gemPath); // NOI18N } }
/** * Checks whether the platform has a valid Rake installed. * * @param warn whether to show warning message to the user if ther is no * valid Rake installed */ public boolean hasValidRake(boolean warn) { boolean valid = isValid(warn) && hasRubyGemsInstalled(warn); String rakePath = getRake(); valid = (rakePath != null) && new File(rakePath).exists(); possiblyNotifyUser(warn, valid, "rake"); // NOI18N return valid; }
RubyPlatform platform = original.getPlatform(); if (platform != null) { String home = platform.getHome().getPath(); exclude.append(home.replace('\\', '/').replace("/", "\\/")); // NOI18N if (platform.hasRubyGemsInstalled()) { GemManager gemManager = platform.getGemManager(); if (gemManager != null) { String gemHome = gemManager.getGemHome();
public RubyExecutionDescriptor(final RubyPlatform platform, final String displayName, final File pwd, final String script) { this.platform = platform; this.displayName = displayName; this.pwd = pwd; this.script = script; this.useInterpreter = true; assert (pwd == null) || pwd.isDirectory() : pwd + " is a directory"; if (platform.hasRubyGemsInstalled()) { Map<String, String> env = new HashMap<String, String>(); GemManager.adjustEnvironment(platform, env); addAdditionalEnv(env); } if (platform.isJRuby()) { Map<String, String> env = new HashMap<String, String>(); String home = platform.getHome().getAbsolutePath(); env.put("JRUBY_HOME", home); // NOI18N env.put("JRUBY_BASE", home); // NOI18N env.put("JAVA_HOME", ExecutionUtils.getJavaHome()); // NOI18N addAdditionalEnv(env); } }
RubyPlatform platform = RubyPlatform.platformFor(project); if (location == null) { gemLocation = FileUtil.toFile(railsInstall); } else { String version = platform.getGemManager().getLatestVersion("rails"); // NOI18N if (version != null) { gemLocation = new File(platform.getGemManager().getGemHome() + File.separator + "gems" + File.separator + "rails" + "-" + version); // NOI18N } else if (!Utilities.isWindows()) { File rubyHome = platform.getHome(); if (rubyHome != null) { File railsDir = new File(rubyHome, "/share/rails/railties"); // NOI18N
private static List<RailsDatabaseConfiguration> getMySQLAdapters(RubyPlatform platform) { if (!platform.isJRuby()) { return Collections.<RailsDatabaseConfiguration>singletonList(new MySQLAdapter()); } GemManager gemManager = platform.getGemManager(); if (gemManager == null || !gemManager.isGemInstalled(JdbcMySQlAdapter.GEM_NAME)) { return Collections.<RailsDatabaseConfiguration>singletonList(new MySQLAdapter()); } return Collections.<RailsDatabaseConfiguration>singletonList(new JdbcMySQlAdapter()); }
private GemManager getGemManager() { if (!EventQueue.isDispatchThread()) { Exceptions.printStackTrace(new AssertionError("getGemManager() must be called from EDT")); } RubyPlatform platform = getSelectedPlatform(); return platform == null ? null : platform.getGemManager(); }
/** * Tries to find a {@link GemManager gem manager} for a given project, or * strictly speaking, for its {@link RubyPlatform platform}. Might return * <tt>null</tt>. */ @CheckForNull public static GemManager gemManagerFor(final Project project) { RubyPlatform platform = RubyPlatform.platformFor(project); return platform == null ? null : platform.getGemManager(); }
public synchronized String getRake() { if (rake == null) { rake = findExecutable("rake"); // NOI18N if (rake != null && !(new File(rake).exists()) && getGemManager().getLatestVersion("rake") != null) { // NOI18N // On Windows, rake does funny things - you may only get a rake.bat InstalledFileLocator locator = InstalledFileLocator.getDefault(); File f = locator.locate("modules/org-netbeans-modules-ruby-project.jar", // NOI18N null, false); if (f == null) { throw new RuntimeException("Can't find cluster"); // NOI18N } f = new File(f.getParentFile().getParentFile().getAbsolutePath() + File.separator + "rake"); // NOI18N try { rake = f.getCanonicalPath(); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } } } return rake; }
/** * The same as {@link #findExecutable(String)}, but if fails and withSuffix * is set to true, it tries to find also executable with the suffix with * which was compiled the interpreter. E.g. for <em>ruby1.8.6-p111</em> * tries to find <em>irb1.8.6-p111</em>. * * @param toFind see {@link #findExecutable(String)} * @param withSuffix whether to try also suffix version when non-suffix is not found * @return see {@link #findExecutable(String)} */ private String findExecutable(final String toFind, final boolean searchInRubyGems, final boolean withSuffix) { String exec = findExecutable(toFind, searchInRubyGems); if (exec == null && withSuffix && !isJRuby()) { // JRuby is not compiled with custom suffix String name = new File(getInterpreter(true)).getName(); if (name.startsWith("ruby")) { // NOI18N String suffix = name.substring(4); // Try to find with suffix (#120441) exec = findExecutable(toFind + suffix, searchInRubyGems); } } return exec; }
/** * Calls {@link #hasRubyGemsInstalled(boolean)} with <tt>false</tt> for warn * parameter. */ public boolean hasRubyGemsInstalled() { return hasRubyGemsInstalled(false); }
public @Override String toString() { return "RubyPlatform[id:" + getID() + ", label:" + getLabel() + ", " + getInterpreter() + ", info: " + info + "]"; // NOI18N }