Examples of runScriptlet()


Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

  }

  @Test
  public void testArray() throws IOException {
    ScriptingContainer sc = new ScriptingContainer();
    Object context = sc.runScriptlet("class Test\ndef test()\n  [\"fred\",\"fred\"]\nend\nend\nTest.new\n");
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile(new StringReader("{{#test}}{{.}}{{/test}}"), "test");
    Writer writer = new StringWriter();
    writer = m.execute(writer, context);
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

    assertEquals(getContents(root, "complex.txt"), writer.toString());
  }

  private Object makeComplex() {
    ScriptingContainer sc = new ScriptingContainer();
    return sc.runScriptlet(JRubyBenchmarkTest.class.getResourceAsStream("complex.rb"), "complex.rb");
  }

  @Test
  public void testComplexBench() throws MustacheException, IOException {
    if (skip()) return;
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

        maven.put("classpath", p.toString());

        getLog().info("Creating classpath script: " + classpathRb);
        ScriptingContainer container = new ScriptingContainer();
        container.put("maven", maven);
        container.runScriptlet(getClass().getResourceAsStream("/dump_classpath.rb"), "dump_classpath.rb");
    }
}
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

        container.put("@weather", new String[] {"snow", "sleet", "drizzle", "rain"});
        container.put("trees", new String[] {"cypress", "hemlock", "spruce"});
        assertTrue(instance.size() == 5);
       
        // persistent local variable should be kept even after eval, plus retrieved.
        container.runScriptlet("a = 1");
        assertTrue(instance.size() == 6);
       
        container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.GLOBAL);
        instance = container.getVarMap();
        container.put("ARGV", new String[] {"spring", "fall"});
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

        // $sports and @weather are not eligible key for local global type.
        assertTrue(instance.size() == 3);
       
        // local global variable should not be dropped.
        // "a" in Ruby code is not local global var.
        container.runScriptlet("a = 1");
        assertTrue(instance.size() == 3);
       
    }

    /**
 
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

       
        // eager retieval mode test
        container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.GLOBAL, false);
        instance = container.getVarMap();
        assertTrue(instance.isEmpty());
        container.runScriptlet("$SEASON = ['mid-winter', 'late-summer']; ARGV << \"St. Patrick's day\"");
        assertTrue(instance.containsKey("SEASON"));
        assertTrue(instance.containsKey("ARGV"));
        assertFalse(instance.containsKey("trees"));
        assertEquals(2, instance.size());
       
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

       
        // lazy retieval mode test
        container = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.GLOBAL, true);
        instance = container.getVarMap();
        assertTrue(instance.isEmpty());
        container.runScriptlet("$SEASON = ['mid-winter', 'late-summer']; ARGV << \"St. Patrick's day\"");
        assertFalse(instance.containsKey("SEASON"));
        List<String> expResult1 = Arrays.asList("mid-winter", "late-summer");
        List<String> result1 = (List<String>) container.get("SEASON");
        assertEquals(expResult1, result1);
        assertTrue(instance.containsKey("SEASON"));
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

        ArrayList<String> lvar_values = new ArrayList<String>();
        lvar_values.add("cypress"); lvar_values.add("hemlock"); lvar_values.add("spruce");
        container.put("trees", lvar_values);
        assertTrue(instance.containsValue(lvar_values));
       
        container.runScriptlet("ARGV << \"late-fall\"; SEASON << \"mid-summer\"; $sports << \"basketball\"; @weather << \"freezing-rain\"");
        argv_values.add("late-fall");
        const_values.add("mid-summer");
        gvar_values.add("basketball");
        ivar_values.add("freezing-rain");
       
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

        container.put("@weather", ivar_values);
        assertFalse(instance.containsValue(ivar_values));
        container.put("trees", lvar_values);
        assertTrue(instance.containsValue(lvar_values));
        container.runScriptlet("ARGV << \"early-winter\"; $SEASON << \"deep-fall\"; $trees << \"pine\"");
        argv_values.add("early-winter");
        const_values.add("deep-fall");
        lvar_values.add("pine");
       
        // eager retrival mode. no need to get before containesValue method
View Full Code Here

Examples of org.jruby.embed.ScriptingContainer.runScriptlet()

            "  end\n" +
            "  def cloud_names\n" +
            "    @@clouds\n" +
            "  end\n" +
            "end";
        container.runScriptlet(script);
    
        Object klazz = container.get("Forecast");
        assertEquals("Forecast", ((RubyClass)klazz).getName());
        Object receiver = container.callMethod(klazz, "new", "blizzard", "6F");
        assertEquals("blizzard", container.get(receiver, "@weather"));
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.