org.jruby.Ruby.getENV()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.jruby.Ruby.getENV方法的一些代码示例,展示了Ruby.getENV的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getENV方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getENV

Ruby.getENV介绍

暂无

代码示例

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Check if HOME environment variable is not nil nor empty
  3. * @param context
  4. */
  5. private static void checkHome(ThreadContext context) {
  6. Ruby runtime = context.runtime;
  7. RubyHash env = runtime.getENV();
  8. String home = (String) env.get(runtime.newString("HOME"));
  9. if (home == null || home.equals("")) {
  10. throw runtime.newArgumentError("couldn't find HOME environment -- expanding `~'");
  11. }
  12. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Check if HOME environment variable is not nil nor empty
  3. * @param context
  4. */
  5. private static void checkHome(ThreadContext context) {
  6. Ruby runtime = context.runtime;
  7. RubyHash env = runtime.getENV();
  8. String home = (String) env.get(runtime.newString("HOME"));
  9. if (home == null || home.equals("")) {
  10. throw runtime.newArgumentError("couldn't find HOME environment -- expanding `~'");
  11. }
  12. }

代码示例来源:origin: org.jruby/jruby-complete

  1. public static RubyString getHomeDirectoryPath(ThreadContext context) {
  2. final RubyString homeKey = RubyString.newStringShared(context.runtime, HOME);
  3. return getHomeDirectoryPath(context, context.runtime.getENV().op_aref(context, homeKey));
  4. }

代码示例来源:origin: org.jruby/jruby-core

  1. public static RubyString getHomeDirectoryPath(ThreadContext context) {
  2. final RubyString homeKey = RubyString.newStringShared(context.runtime, HOME);
  3. return getHomeDirectoryPath(context, context.runtime.getENV().op_aref(context, homeKey));
  4. }

代码示例来源:origin: org.jruby/jruby-complete

  1. public static String getEnvTimeZone(Ruby runtime) {
  2. RubyString tz = runtime.tzVar;
  3. if (tz == null) {
  4. tz = runtime.newString(TZ_STRING);
  5. tz.setFrozen(true);
  6. runtime.tzVar = tz;
  7. }
  8. RubyHash.RubyHashEntry entry = runtime.getENV().getEntry(tz);
  9. if (entry.key == null || entry.key == NEVER) return null; // NO_ENTRY
  10. if (entry.key != tz) runtime.tzVar = (RubyString) entry.key;
  11. return (entry.value instanceof RubyString) ? ((RubyString) entry.value).asJavaString() : null;
  12. }

代码示例来源:origin: org.jruby/jruby-complete

  1. /**
  2. * Check if HOME environment variable is not nil nor empty
  3. * @param context
  4. */
  5. private static RubyString checkHome(ThreadContext context) {
  6. Ruby runtime = context.runtime;
  7. IRubyObject home = runtime.getENV().fastARef(RubyString.newStringShared(runtime, RubyDir.HOME));
  8. if (home == null || home == context.nil || ((RubyString) home).size() == 0) {
  9. throw runtime.newArgumentError("couldn't find HOME environment -- expanding `~'");
  10. }
  11. return (RubyString) home;
  12. }

代码示例来源:origin: org.jruby/jruby-core

  1. public static String getEnvTimeZone(Ruby runtime) {
  2. RubyString tz = runtime.tzVar;
  3. if (tz == null) {
  4. tz = runtime.newString(TZ_STRING);
  5. tz.setFrozen(true);
  6. runtime.tzVar = tz;
  7. }
  8. RubyHash.RubyHashEntry entry = runtime.getENV().getEntry(tz);
  9. if (entry.key == null || entry.key == NEVER) return null; // NO_ENTRY
  10. if (entry.key != tz) runtime.tzVar = (RubyString) entry.key;
  11. return (entry.value instanceof RubyString) ? ((RubyString) entry.value).asJavaString() : null;
  12. }

代码示例来源:origin: org.jruby/jruby-core

  1. /**
  2. * Check if HOME environment variable is not nil nor empty
  3. * @param context
  4. */
  5. private static RubyString checkHome(ThreadContext context) {
  6. Ruby runtime = context.runtime;
  7. IRubyObject home = runtime.getENV().fastARef(RubyString.newStringShared(runtime, RubyDir.HOME));
  8. if (home == null || home == context.nil || ((RubyString) home).size() == 0) {
  9. throw runtime.newArgumentError("couldn't find HOME environment -- expanding `~'");
  10. }
  11. return (RubyString) home;
  12. }

代码示例来源:origin: org.jruby.rack/jruby-rack

  1. @SuppressWarnings("unchecked")
  2. void doInitialize(final Ruby runtime) {
  3. setOut( runtime.getOut() );
  4. setErr( runtime.getErr() );
  5. rubyENV = runtime.getENV();
  6. compatVersion = runtime.getInstanceConfig().getCompatVersion();
  7. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. @JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9)
  2. public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
  3. Ruby runtime = context.runtime;
  4. if (args[0] instanceof RubyHash) {
  5. RubyHash env = (RubyHash) args[0].convertToHash();
  6. if (env != null) {
  7. runtime.getENV().merge_bang(context, env, Block.NULL_BLOCK);
  8. }
  9. // drop the first element for calling systemCommon()
  10. IRubyObject[] rest = new IRubyObject[args.length - 1];
  11. System.arraycopy(args, 1, rest, 0, args.length - 1);
  12. args = rest;
  13. }
  14. int resultCode = systemCommon(context, recv, args);
  15. switch (resultCode) {
  16. case 0: return runtime.getTrue();
  17. case 127: return runtime.getNil();
  18. default: return runtime.getFalse();
  19. }
  20. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. @JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9)
  2. public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
  3. Ruby runtime = context.runtime;
  4. if (args[0] instanceof RubyHash) {
  5. RubyHash env = (RubyHash) args[0].convertToHash();
  6. if (env != null) {
  7. runtime.getENV().merge_bang(context, env, Block.NULL_BLOCK);
  8. }
  9. // drop the first element for calling systemCommon()
  10. IRubyObject[] rest = new IRubyObject[args.length - 1];
  11. System.arraycopy(args, 1, rest, 0, args.length - 1);
  12. args = rest;
  13. }
  14. int resultCode = systemCommon(context, recv, args);
  15. switch (resultCode) {
  16. case 0: return runtime.getTrue();
  17. case 127: return runtime.getNil();
  18. default: return runtime.getFalse();
  19. }
  20. }

代码示例来源:origin: org.jruby/jruby-complete

  1. static RubyString getHomeDirectoryPath(ThreadContext context, IRubyObject home) {
  2. final Ruby runtime = context.runtime;
  3. if (home == null || home == context.nil) {
  4. IRubyObject ENV_JAVA = runtime.getObject().getConstant("ENV_JAVA");
  5. home = ENV_JAVA.callMethod(context, "[]", RubyString.newString(runtime, user_home, UTF8));
  6. }
  7. if (home == null || home == context.nil) {
  8. home = context.runtime.getENV().op_aref(context, runtime.newString("LOGDIR"));
  9. }
  10. if (home == null || home == context.nil) {
  11. throw runtime.newArgumentError("user.home/LOGDIR not set");
  12. }
  13. return (RubyString) home;
  14. }

代码示例来源:origin: org.jruby/jruby-core

  1. static RubyString getHomeDirectoryPath(ThreadContext context, IRubyObject home) {
  2. final Ruby runtime = context.runtime;
  3. if (home == null || home == context.nil) {
  4. IRubyObject ENV_JAVA = runtime.getObject().getConstant("ENV_JAVA");
  5. home = ENV_JAVA.callMethod(context, "[]", RubyString.newString(runtime, user_home, UTF8));
  6. }
  7. if (home == null || home == context.nil) {
  8. home = context.runtime.getENV().op_aref(context, runtime.newString("LOGDIR"));
  9. }
  10. if (home == null || home == context.nil) {
  11. throw runtime.newArgumentError("user.home/LOGDIR not set");
  12. }
  13. return (RubyString) home;
  14. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. RubyHash envMap = env.convertToHash();
  2. if (envMap != null) {
  3. runtime.getENV().merge_bang(context, envMap, Block.NULL_BLOCK);
  4. for (Map.Entry<String, String> envEntry : ((Map<String, String>)runtime.getENV()).entrySet()) {
  5. envStrings.add(envEntry.getKey() + "=" + envEntry.getValue());

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. RubyHash envMap = env.convertToHash();
  2. if (envMap != null) {
  3. runtime.getENV().merge_bang(context, envMap, Block.NULL_BLOCK);
  4. for (Map.Entry<String, String> envEntry : ((Map<String, String>)runtime.getENV()).entrySet()) {
  5. envStrings.add(envEntry.getKey() + "=" + envEntry.getValue());

代码示例来源:origin: org.jruby/jruby-core

  1. RubyHash envMap = env.convertToHash();
  2. if (envMap != null) {
  3. runtime.getENV().merge_bang(context, envMap, Block.NULL_BLOCK);
  4. final Map<String, String> ENV = (Map<String, String>) runtime.getENV();
  5. ArrayList<String> envStrings = new ArrayList<>(ENV.size() + 1);
  6. for ( Map.Entry<String, String> envEntry : ENV.entrySet() ) {

代码示例来源:origin: org.jruby/jruby-complete

  1. RubyHash envMap = env.convertToHash();
  2. if (envMap != null) {
  3. runtime.getENV().merge_bang(context, envMap, Block.NULL_BLOCK);
  4. final Map<String, String> ENV = (Map<String, String>) runtime.getENV();
  5. ArrayList<String> envStrings = new ArrayList<>(ENV.size() + 1);
  6. for ( Map.Entry<String, String> envEntry : ENV.entrySet() ) {

代码示例来源:origin: org.jruby/jruby-complete

  1. runtime.getENV().merge_bang(context, (RubyHash) args[0], Block.NULL_BLOCK);

代码示例来源:origin: org.jruby/jruby-core

  1. runtime.getENV().merge_bang(context, (RubyHash) args[0], Block.NULL_BLOCK);

相关文章

Ruby类方法