Package org.jruby

Examples of org.jruby.Ruby.parseEval()


        EmbedEvalUnit result = instance.parse(script, lines);
        assertEquals(expResult, result);

        script = "";
        Ruby runtime = JavaEmbedUtils.initialize(new ArrayList());
        Node node = runtime.parseEval(script, "<script>", null, 0);
        IRubyObject expRet = runtime.runInterpreter(node);
        result = instance.parse(script);
        IRubyObject ret = result.run();
        assertEquals(expRet.toJava(String.class), ret.toJava(String.class));
        // Maybe bug. This returns RubyNil, but it should be ""
View Full Code Here


        script = "# -*- coding: utf-8 -*-\n" +
                 "def say_something()" +
                   "\"はろ〜、わぁ〜るど!\"\n" +
                 "end\n" +
                 "say_something";
        expRet = runtime.runInterpreter(runtime.parseEval(script, "<script>", null, 0));
        ret = instance.parse(script).run();
        assertEquals(expRet.toJava(String.class), ret.toJava(String.class));

        //sharing variables
        instance.put("what", "Trick or Treat.");
View Full Code Here

            if (sharing_variables) {
                scope = getManyVarsDynamicScope(container, 0);
            }
            Node node = null;
            if (input instanceof String) {
                node = runtime.parseEval((String)input, filename, scope, line);
            } else {
                node = runtime.parseFile((InputStream)input, filename, scope, line);
            }
            CompileMode compileMode = runtime.getInstanceConfig().getCompileMode();
            if (compileMode == CompileMode.FORCE) {
View Full Code Here

   * @throws JumpException in case of JRuby parsing failure
   */
  public static Object createJRubyObject(String scriptSource, Class<?>[] interfaces, ClassLoader classLoader) {
    Ruby ruby = initializeRuntime();

    Node scriptRootNode = ruby.parseEval(scriptSource, "", null, 0);
        IRubyObject rubyObject = ruby.runNormally(scriptRootNode);

    if (rubyObject instanceof RubyNil) {
      String className = findClassName(scriptRootNode);
      rubyObject = ruby.evalScriptlet("\n" + className + ".new");
View Full Code Here

   * @throws JumpException in case of JRuby parsing failure
   */
  public static Object createJRubyObject(String scriptSource, Class[] interfaces, ClassLoader classLoader) {
    Ruby ruby = initializeRuntime();

    Node scriptRootNode = ruby.parseEval(scriptSource, "", null, 0);
    // keep using the deprecated runNormally variant for JRuby 1.1/1.2 compatibility...
    IRubyObject rubyObject = ruby.runNormally(scriptRootNode, false);

    if (rubyObject instanceof RubyNil) {
      String className = findClassName(scriptRootNode);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.