Examples of runScriptlet()


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

public class SimpleTest {

    @Test
    public void test() throws Exception {
        IsolatedScriptingContainer container = new IsolatedScriptingContainer();
  String output = (String) container.runScriptlet("require 'hello';Hello.new( :name => 'world' ).say");

        assertTrue( output, output.contains( "hello world" ) );
        assertTrue( output, output.contains( "zip file name: world" ) );
    }
View Full Code Here

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

    ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
    // TODO: handle RUBY LOAD PATH to allow non JRuby dev
    List<String> loadPaths = new ArrayList<String>();
    loadPaths.add(_appPath);
    container.getProvider().setLoadPaths(loadPaths);
    container.runScriptlet("ENV['SIPATRA_PATH'] = '" + _appPath.replaceAll("'", "\'") + "'");
    container.runScriptlet(PathType.CLASSPATH, "sipatra.rb");

    if(_scriptPath != null)
    {
      File file = new File(_scriptPath);
View Full Code Here

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

    // TODO: handle RUBY LOAD PATH to allow non JRuby dev
    List<String> loadPaths = new ArrayList<String>();
    loadPaths.add(_appPath);
    container.getProvider().setLoadPaths(loadPaths);
    container.runScriptlet("ENV['SIPATRA_PATH'] = '" + _appPath.replaceAll("'", "\'") + "'");
    container.runScriptlet(PathType.CLASSPATH, "sipatra.rb");

    if(_scriptPath != null)
    {
      File file = new File(_scriptPath);
      if(file.isFile())
View Full Code Here

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

    if(_scriptPath != null)
    {
      File file = new File(_scriptPath);
      if(file.isFile())
        container.runScriptlet(PathType.ABSOLUTE, file.getAbsolutePath());
      else if(file.isDirectory())
      {
        for(File f : file.listFiles())
        {
          if(f.getName().endsWith(".rb"))
View Full Code Here

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

      else if(file.isDirectory())
      {
        for(File f : file.listFiles())
        {
          if(f.getName().endsWith(".rb"))
            container.runScriptlet(PathType.ABSOLUTE, f.getAbsolutePath());
        }
      }
    }
    return container;
  }
View Full Code Here

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

      GenericObjectPool pool = (GenericObjectPool) message.getSession().getServletContext().getAttribute(Attributes.POOL);
      container = (ScriptingContainer) pool.borrowObject();
            long beginTime = System.currentTimeMillis();
      try
      {
        Object app = container.runScriptlet("Sipatra::Application::new");

        container.callMethod(app, "set_bindings", new Object[] {
            message.getSession().getServletContext()
            message.getSession().getServletContext().getAttribute(SipServlet.SIP_FACTORY),
            message.getSession(),
View Full Code Here

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

public class TestFactory extends TestCase{

  public void testFactory(){
   
    ScriptingContainer c = RubyStepFactory.createScriptingContainer(false, RubyVersion.RUBY_1_8);
    c.runScriptlet("puts \"Ruby version: #{RUBY_VERSION}\"");
   
  }
 
  public void testJDBCDrivers(){
    // this is a regression test for JDBC drivers disappearing from the JVM, since jruby may
View Full Code Here

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

    // if the script can be executed repeatedly, all is fine. It raises an exception
    // if the driver got unregistered at some point.
    for (int i=1;i<=5;i++){
      ScriptingContainer c = RubyStepFactory.createScriptingContainer(false, RubyVersion.RUBY_1_8);
      c.runScriptlet(testScript);
      c.terminate();
      System.out.println("Testing JDBC Driver persistence: iteration "+i);
    }
   
  }
View Full Code Here

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

public class JRubyTest {
  @Test
  public void testHash() throws IOException {
    ScriptingContainer sc = new ScriptingContainer();
    Object context = sc.runScriptlet("{:test=>'fred'}");
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile(new StringReader("{{test}}"), "test");
    Writer writer = new StringWriter();
    writer = m.execute(writer, context);
View Full Code Here

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

  }

  @Test
  public void testObject() throws IOException {
    ScriptingContainer sc = new ScriptingContainer();
    Object context = sc.runScriptlet("class Test\ndef test()\n  \"fred\"\nend\nend\nTest.new\n");
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile(new StringReader("{{test}}"), "test");
    Writer writer = new StringWriter();
    writer = m.execute(writer, context);
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.