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

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

本文整理了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

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

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

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

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

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

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

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

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

public static String getEnvTimeZone(Ruby runtime) {
  RubyString tz = runtime.tzVar;
  if (tz == null) {
    tz = runtime.newString(TZ_STRING);
    tz.setFrozen(true);
    runtime.tzVar = tz;
  }
  
  RubyHash.RubyHashEntry entry = runtime.getENV().getEntry(tz);
  if (entry.key == null || entry.key == NEVER) return null; // NO_ENTRY
  if (entry.key != tz) runtime.tzVar = (RubyString) entry.key;
  return (entry.value instanceof RubyString) ? ((RubyString) entry.value).asJavaString() : null;
}

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

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

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

public static String getEnvTimeZone(Ruby runtime) {
  RubyString tz = runtime.tzVar;
  if (tz == null) {
    tz = runtime.newString(TZ_STRING);
    tz.setFrozen(true);
    runtime.tzVar = tz;
  }
  
  RubyHash.RubyHashEntry entry = runtime.getENV().getEntry(tz);
  if (entry.key == null || entry.key == NEVER) return null; // NO_ENTRY
  if (entry.key != tz) runtime.tzVar = (RubyString) entry.key;
  return (entry.value instanceof RubyString) ? ((RubyString) entry.value).asJavaString() : null;
}

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

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

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

@SuppressWarnings("unchecked")
void doInitialize(final Ruby runtime) {
  setOut( runtime.getOut() );
  setErr( runtime.getErr() );
  rubyENV = runtime.getENV();
  compatVersion = runtime.getInstanceConfig().getCompatVersion();
}

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

@JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9)
public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
  Ruby runtime = context.runtime;
  if (args[0] instanceof RubyHash) {
    RubyHash env = (RubyHash) args[0].convertToHash();
    if (env != null) {
      runtime.getENV().merge_bang(context, env, Block.NULL_BLOCK);
    }
    // drop the first element for calling systemCommon()
    IRubyObject[] rest = new IRubyObject[args.length - 1];
    System.arraycopy(args, 1, rest, 0, args.length - 1);
    args = rest;
  }
  int resultCode = systemCommon(context, recv, args);
  switch (resultCode) {
    case 0: return runtime.getTrue();
    case 127: return runtime.getNil();
    default: return runtime.getFalse();
  }
}

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

@JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9)
public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
  Ruby runtime = context.runtime;
  if (args[0] instanceof RubyHash) {
    RubyHash env = (RubyHash) args[0].convertToHash();
    if (env != null) {
      runtime.getENV().merge_bang(context, env, Block.NULL_BLOCK);
    }
    // drop the first element for calling systemCommon()
    IRubyObject[] rest = new IRubyObject[args.length - 1];
    System.arraycopy(args, 1, rest, 0, args.length - 1);
    args = rest;
  }
  int resultCode = systemCommon(context, recv, args);
  switch (resultCode) {
    case 0: return runtime.getTrue();
    case 127: return runtime.getNil();
    default: return runtime.getFalse();
  }
}

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

static RubyString getHomeDirectoryPath(ThreadContext context, IRubyObject home) {
  final Ruby runtime = context.runtime;
  if (home == null || home == context.nil) {
    IRubyObject ENV_JAVA = runtime.getObject().getConstant("ENV_JAVA");
    home = ENV_JAVA.callMethod(context, "[]", RubyString.newString(runtime, user_home, UTF8));
  }
  if (home == null || home == context.nil) {
    home = context.runtime.getENV().op_aref(context, runtime.newString("LOGDIR"));
  }
  if (home == null || home == context.nil) {
    throw runtime.newArgumentError("user.home/LOGDIR not set");
  }
  return (RubyString) home;
}

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

static RubyString getHomeDirectoryPath(ThreadContext context, IRubyObject home) {
  final Ruby runtime = context.runtime;
  if (home == null || home == context.nil) {
    IRubyObject ENV_JAVA = runtime.getObject().getConstant("ENV_JAVA");
    home = ENV_JAVA.callMethod(context, "[]", RubyString.newString(runtime, user_home, UTF8));
  }
  if (home == null || home == context.nil) {
    home = context.runtime.getENV().op_aref(context, runtime.newString("LOGDIR"));
  }
  if (home == null || home == context.nil) {
    throw runtime.newArgumentError("user.home/LOGDIR not set");
  }
  return (RubyString) home;
}

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

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

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

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

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

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

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

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

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

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

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

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

相关文章

Ruby类方法