Package org.jruby.environment

Examples of org.jruby.environment.OSEnvironment


    }

    private static void defineGlobalEnvConstants(Ruby runtime) {

      Map environmentVariableMap = null;
      OSEnvironment environment = new OSEnvironment();
      try {
        environmentVariableMap = environment.getEnvironmentVariableMap(runtime);
      } catch (OSEnvironmentReaderExcepton e) {
        // If the environment variables are not accessible shouldn't terminate
        runtime.getWarnings().warn(ID.MISCELLANEOUS, e.getMessage());
      }
   
      if (environmentVariableMap == null) {
            // if the environment variables can't be obtained, define an empty ENV
        environmentVariableMap = new HashMap();
      }

        StringOnlyRubyHash h1 = new StringOnlyRubyHash(runtime,
                                                       environmentVariableMap, runtime.getNil());
        h1.getSingletonClass().defineAnnotatedMethods(StringOnlyRubyHash.class);
        runtime.defineGlobalConstant("ENV", h1);

        // Define System.getProperties() in ENV_JAVA
        Map systemProps = environment.getSystemPropertiesMap(runtime);
        runtime.defineGlobalConstant("ENV_JAVA", new StringOnlyRubyHash(
                runtime, systemProps, runtime.getNil()));
       
    }
View Full Code Here

TOP

Related Classes of org.jruby.environment.OSEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.