private static RubyPlatform findDefaultPlatform() { String path = RubyInstallation.getInstance().getJRuby(); return path == null ? null : new RubyPlatform(PLATFORM_ID_DEFAULT, path, Info.forDefaultPlatform()); }
private String getJRubyBin() { String jh = getJRubyHome(); if (jh != null) { return jh + File.separator + "bin"; // NOI18N } else { return null; } }
static Ruby getRuntime(final JTextComponent text) { final TextAreaReadline tar = new TextAreaReadline(text, " " + NbBundle.getMessage(IrbTopComponent.class, "IrbWelcome") + " \n\n"); // NOI18N // Ensure that ClassPath can find libraries etc. RubyInstallation.getInstance().setJRubyLoadPaths(); final PipedInputStream pipeIn = new PipedInputStream(); final RubyInstanceConfig config = new RubyInstanceConfig() {{ setInput(pipeIn); setOutput(new PrintStream(tar.getOutputStream())); setError(new PrintStream(tar.getOutputStream())); setObjectSpaceEnabled(false); //setArgv(args); }}; final Ruby runtime = Ruby.newInstance(config); runtime.getGlobalVariables().defineReadonly("$$", new ValueAccessor(runtime.newFixnum(System.identityHashCode(runtime)))); runtime.getLoadService().init(new ArrayList()); tar.hookIntoRuntime(runtime); return runtime; }
public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() == RubyInstallation.getInstance() && evt.getPropertyName().equals("roots")) { resetCache(); } // if (evt.getSource() == this.evaluator && evt.getPropertyName().equals(PLATFORM_ACTIVE)) { // //Active platform was changed // resetCache (); // } // else if (evt.getSource() == this.platformManager && JavaPlatformManager.PROP_INSTALLED_PLATFORMS.equals(evt.getPropertyName()) && activePlatformName != null) { // //Platform definitions were changed, check if the platform was not resolved or deleted // if (this.isActivePlatformValid) { // if (RubyProjectUtil.getActivePlatform (this.activePlatformName) == null) { // //the platform was not removed // this.resetCache(); // } // } // else { // if (RubyProjectUtil.getActivePlatform (this.activePlatformName) != null) { // this.resetCache(); // } // } // } }
public String getJRuby() { String binDir = getJRubyBin(); if (binDir == null) { return null; } String binary = Utilities.isWindows() ? "jruby.bat" : "jruby"; // NOI18N String jruby = binDir + File.separator + binary; // Normalize path try { jruby = new File(jruby).getCanonicalFile().getAbsolutePath(); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } if (!new File(jruby).isFile()) { return null; } return jruby; }
@Override public void propertyChange(PropertyChangeEvent evt) { if ((evt.getSource() == RubyInstallation.getInstance() && evt.getPropertyName().equals("roots")) || evt.getSource() == RubyPreferences.getInstance() && evt.getPropertyName().equals(RubyPreferences.VENDOR_GEMS_PROPERTY)) { resetCache(); } if (evt.getPropertyName().equals(SharedRubyProjectProperties.PLATFORM_ACTIVE)) { platform = RubyPlatformProvider.getPlatform((String) evt.getNewValue()); resetCache(); } if (evt.getPropertyName().equals(RequiredGems.REQUIRED_GEMS_TESTS_PROPERTY) && forTests) { requiredGems.setRequiredGems((String) evt.getNewValue()); resetCache(); } if (evt.getPropertyName().equals(RequiredGems.REQUIRED_GEMS_PROPERTY) && !forTests) { requiredGems.setRequiredGems((String) evt.getNewValue()); resetCache(); } }
String binDirPath = getJRubyBin(); if (binDirPath == null) { return;
public void setJRubyLoadPaths() { String jh = getJRubyHome(); if (jh != null) { System.setProperty("jruby.home", jh); // NOI18N } }