private void initEnvironment() { try { setEnvironment(System.getenv()); } catch (SecurityException se) { /* ignore missing getenv permission */ } }
private void initEnvironment() { try { setEnvironment(System.getenv()); } catch (SecurityException se) { /* ignore missing getenv permission */ } }
/** * Changes an environment variables' map. * Call this method before you use put/get, runScriptlet, and parse methods so that * initial configurations will work. * * @since JRuby 1.5.0. * * @param environment a new map of environment variables. */ public void setEnvironment(Map environment) { provider.getRubyInstanceConfig().setEnvironment(environment); }
/** * Changes an environment variables' map. * Call this method before you use put/get, runScriptlet, and parse methods so that * initial configurations will work. * * @since JRuby 1.5.0. * * @param environment a new map of environment variables. */ public void setEnvironment(Map environment) { provider.getRubyInstanceConfig().setEnvironment(environment); }
/** * Changes an environment variables' map. * Call this method before you use put/get, runScriptlet, and parse methods so that * initial configurations will work. * * @since JRuby 1.5.0. * * @param environment a new map of environment variables. */ public void setEnvironment(Map environment) { provider.getRubyInstanceConfig().setEnvironment(environment); }
/** * Changes an environment variables' map. * Call this method before you use put/get, runScriptlet, and parse methods so that * initial configurations will work. * * @since JRuby 1.5.0. * * @param environment a new map of environment variables. */ public void setEnvironment(Map environment) { provider.getRubyInstanceConfig().setEnvironment(environment); }
void inject(Map<String, String> environmentVars) { if (!environmentVars.isEmpty()) { Map<String, String> replacementEnv = new HashMap<String, String>(System.getenv()); for (Map.Entry<String, String> envVar : environmentVars.entrySet()) { String key = envVar.getKey(); String val = envVar.getValue(); if (val == null || "".equals(val)) { replacementEnv.remove(envVar.getKey()); if ("GEM_PATH".equals(key) && !environmentVars.containsKey("GEM_HOME")) { replacementEnv.remove("GEM_HOME"); } } else { replacementEnv.put(key, val); if ("GEM_PATH".equals(key) && !environmentVars.containsKey("GEM_HOME")) { String gemHome = val.toString().split(File.pathSeparator)[0]; replacementEnv.put("GEM_HOME", gemHome); } } } config.setEnvironment(replacementEnv); } } }
void inject(Map<String, String> environmentVars) { if (!environmentVars.isEmpty()) { Map<String, String> replacementEnv = new HashMap<String, String>(System.getenv()); for (Map.Entry<String, String> envVar : environmentVars.entrySet()) { String key = envVar.getKey(); String val = envVar.getValue(); if (val == null || "".equals(val)) { replacementEnv.remove(envVar.getKey()); if ("GEM_PATH".equals(key) && !environmentVars.containsKey("GEM_HOME")) { replacementEnv.remove("GEM_HOME"); } } else { replacementEnv.put(key, val); if ("GEM_PATH".equals(key) && !environmentVars.containsKey("GEM_HOME")) { String gemHome = val.toString().split(File.pathSeparator)[0]; replacementEnv.put("GEM_HOME", gemHome); } } } config.setEnvironment(replacementEnv); } } }
private Ruby createRubyRuntime(String baseDir) throws IOException { RubyInstanceConfig runtimeConfig = createRuntimeConfig(); Map<String, String> env = new HashMap<String, String>(runtimeConfig.getEnvironment()); env.remove("GEM_HOME"); env.remove("GEM_PATH"); env.put("RACK_ENV", "production"); env.put("RAILS_ENV", "production"); runtimeConfig.setEnvironment(env); return JavaEmbedUtils.initialize(ImmutableList.of(baseDir), runtimeConfig); }
public void start() throws IOException { config = new RubyInstanceConfig(parentRuntime.getInstanceConfig()); config.setCurrentDirectory(pwd.toString()); config.setEnvironment(environmentMap(env)); if (pipedStreams) { config.setInput(new PipedInputStream(processInput)); config.setOutput(new PrintStream(new PipedOutputStream(processOutput))); config.setError(new PrintStream(new PipedOutputStream(processError))); } String procName = "piped"; if (argArray.length > 0) { procName = argArray[0]; } processThread = new Thread(this, "ScriptThreadProcess: " + procName); processThread.setDaemon(true); processThread.start(); }
public void start() throws IOException { config = new RubyInstanceConfig(parentRuntime.getInstanceConfig()); config.setEnvironment(environmentMap(env)); config.setCurrentDirectory(pwd.toString()); if (pipedStreams) { config.setInput(new PipedInputStream(processInput)); config.setOutput(new PrintStream(new PipedOutputStream(processOutput))); config.setError(new PrintStream(new PipedOutputStream(processError))); } String procName = "piped"; if (argArray.length > 0) { procName = argArray[0]; } processThread = new Thread(this, "ScriptThreadProcess: " + procName); processThread.setDaemon(true); processThread.start(); }
public void start() throws IOException { config = new RubyInstanceConfig(parentRuntime.getInstanceConfig()); config.setEnvironment(environmentMap(env)); config.setCurrentDirectory(pwd.toString()); if (pipedStreams) { config.setInput(new PipedInputStream(processInput)); config.setOutput(new PrintStream(new PipedOutputStream(processOutput))); config.setError(new PrintStream(new PipedOutputStream(processError))); } String procName = "piped"; if (argArray.length > 0) { procName = argArray[0]; } processThread = new Thread(this, "ScriptThreadProcess: " + procName); processThread.setDaemon(true); processThread.start(); }
public void start() throws IOException { config = new RubyInstanceConfig(parentRuntime.getInstanceConfig()); config.setCurrentDirectory(pwd.toString()); config.setEnvironment(environmentMap(env)); if (pipedStreams) { config.setInput(new PipedInputStream(processInput)); config.setOutput(new PrintStream(new PipedOutputStream(processOutput))); config.setError(new PrintStream(new PipedOutputStream(processError))); } String procName = "piped"; if (argArray.length > 0) { procName = argArray[0]; } processThread = new Thread(this, "ScriptThreadProcess: " + procName); processThread.setDaemon(true); processThread.start(); }
public GemScriptingContainer(LocalContextScope scope, LocalVariableBehavior behavior, final File gemHome, final File gemPath) { super(scope, behavior); final Map<String, String> env = new HashMap<String, String>(); if (gemHome != null && gemHome.exists()) { env.put("GEM_HOME", gemHome.getAbsolutePath()); } if (gemPath != null && gemPath.exists()) { env.put("GEM_PATH", gemPath.getAbsolutePath()); } getProvider().getRubyInstanceConfig().setEnvironment(env); // setting the JRUBY_HOME to the one from the jruby jar - ignoring // the environment setting ! // use lib otherwise the classloader finds META-INF/jruby.home from ruby-tools where there is a bin/rake // as fix for an older jruby jar URL jrubyHome = Thread.currentThread().getContextClassLoader() .getResource("META-INF/jruby.home/lib"); if ( jrubyHome != null ){ getProvider().getRubyInstanceConfig() .setJRubyHome( jrubyHome .toString() .replaceFirst("^jar:", "") .replaceFirst( "/lib$", "" ) ); } }
JRubyMain(String bundleDisableSharedGems, String currentDirectory, String jrubyHome, RubyInstanceConfig config) { super(config); // TODO have property to disable hard exit - see warbler config.setHardExit(true); config.setCurrentDirectory(currentDirectory + "/"); config.setJRubyHome(jrubyHome); // for jruby 1.7.x add the current directory explicitly to LOAD_PATH config.setLoadPaths(Arrays.asList(currentDirectory + "/")); Map<String, String> env = new HashMap<String, String>(System.getenv()); // we assume the embedded jars are placed in jars directory env.put("JARS_HOME", currentDirectory + "/jars"); // we assume the embedded gems are placed at the root of the "archive" env.put("GEM_PATH", currentDirectory + "/"); // make sure we do not inherit it from outside // NOTE: setting it to GEM_PATH will break the extractingMain cases env.put("GEM_HOME", jrubyHome + "/lib/ruby/gems/shared"); if (bundleDisableSharedGems != null) { // for spawning jruby we need bundler to tell to // NOT clean up the load Path env.put("BUNDLE_DISABLE_SHARED_GEMS", bundleDisableSharedGems); } config.setEnvironment(env); // older jruby-1.7.x does need this config.setLoader(JRubyMain.class.getClassLoader()); }
JRubyMain(String bundleDisableSharedGems, String currentDirectory, String jrubyHome, RubyInstanceConfig config) { super(config); // TODO have property to disable hard exit - see warbler config.setHardExit(true); config.setCurrentDirectory(currentDirectory + "/"); config.setJRubyHome(jrubyHome); // for jruby 1.7.x add the current directory explicitly to LOAD_PATH config.setLoadPaths(Arrays.asList(currentDirectory + "/")); Map<String, String> env = new HashMap<String, String>(System.getenv()); // we assume the embedded jars are placed in jars directory env.put("JARS_HOME", currentDirectory + "/jars"); // we assume the embedded gems are placed at the root of the "archive" env.put("GEM_PATH", currentDirectory + "/"); // make sure we do not inherit it from outside // NOTE: setting it to GEM_PATH will break the extractingMain cases env.put("GEM_HOME", jrubyHome + "/lib/ruby/gems/shared"); if (bundleDisableSharedGems != null) { // for spawning jruby we need bundler to tell to // NOT clean up the load Path env.put("BUNDLE_DISABLE_SHARED_GEMS", bundleDisableSharedGems); } config.setEnvironment(env); // older jruby-1.7.x does need this config.setLoader(JRubyMain.class.getClassLoader()); }
public int run(NGContext context) { context.assertLoopbackClient(); RubyInstanceConfig config = new RubyInstanceConfig(); Main main = new Main(config); config.setCurrentDirectory(context.getWorkingDirectory()); config.setEnvironment(OSEnvironment.propertiesToStringMap(context.getEnv())); return main.run(context.getArgs()).getStatus(); } }
public int run(NGContext context) { context.assertLoopbackClient(); RubyInstanceConfig config = new RubyInstanceConfig(); Main main = new Main(config); config.setCurrentDirectory(context.getWorkingDirectory()); config.setEnvironment(context.getEnv()); // reuse one cache of compiled bodies config.setClassCache(classCache); return main.run(context.getArgs()).getStatus(); } }
public int run(NGContext context) { context.assertLoopbackClient(); RubyInstanceConfig config = new RubyInstanceConfig(); Main main = new Main(config); config.setCurrentDirectory(context.getWorkingDirectory()); config.setEnvironment(context.getEnv()); // reuse one cache of compiled bodies config.setClassCache(classCache); return main.run(context.getArgs()).getStatus(); } }
public int run(NGContext context) { context.assertLoopbackClient(); RubyInstanceConfig config = new RubyInstanceConfig(); Main main = new Main(config); config.setCurrentDirectory(context.getWorkingDirectory()); config.setEnvironment(OSEnvironment.propertiesToStringMap(context.getEnv())); return main.run(context.getArgs()).getStatus(); } }