Package org.jruby

Examples of org.jruby.RubyInstanceConfig$LoadServiceCreator


import org.jruby.javasupport.JavaEmbedUtils;

public class Main {

  public static void main(String[] args) throws Exception {  
    RubyInstanceConfig config = new RubyInstanceConfig();
    config.setArgv(args);
    Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
    String mainRubyFile  = "main";
    String runConfigFile = "run_configuration";

    ArrayList<String> config_data = new ArrayList<String>();
View Full Code Here


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        RubyInstanceConfig config = new RubyInstanceConfig();
        Ruby runtime = Ruby.newInstance(config);
        runtime.getLoadService().init(new ArrayList(0));
  runtime.evalScriptlet("require 'src/main.rb'");
    }
View Full Code Here

    }

    private void loadScript(Writer out, Writer err, boolean isDebugging) {
        try {
            if (interpreter == null) {
                RubyInstanceConfig config = new RubyInstanceConfig();
                if (isDebugging)
                    config.setCompileMode(CompileMode.OFF);
                List<String> loadPaths = new ArrayList<String>();
                setModule(loadPaths);
                String appRubyPath = System.getProperty(PROP_APPLICATION_RUBYPATH);
                if (appRubyPath != null) {
                    StringTokenizer tok = new StringTokenizer(appRubyPath, ";");
                    while (tok.hasMoreTokens())
                        loadPaths.add(tok.nextToken().replace('/', File.separatorChar));
                }
                config.setOutput(new PrintStream(new WriterOutputStream(out)));
                config.setError(new PrintStream(new WriterOutputStream(err)));
                interpreter = JavaEmbedUtils.initialize(loadPaths, config);
                interpreter.evalScriptlet("require 'marathon/results'");
            }
            if (type == MarathonAppType.JAVA) {
                interpreter.evalScriptlet("require 'marathon/playback'");
View Full Code Here

            public void windowClosing(WindowEvent e) {
                tar.shutdown();
            }
        });

        final RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(tar.getInputStream());
            setOutput(new PrintStream(tar.getOutputStream()));
            setError(new PrintStream(tar.getOutputStream()));
            setArgv(list.toArray(new String[0]));
        }};
View Full Code Here

            System.out.println("Parsing " + args[0] + " " + iterations + " times");
            RubyParser parser = new Ruby20Parser();
            parser.setWarnings(new NullWarnings(null));
            Ruby runtime = Ruby.getGlobalRuntime();
            RubyInstanceConfig rconfig = new RubyInstanceConfig();
            ParserConfiguration config = new ParserConfiguration(runtime, 0, false, false, true, rconfig);

            for (int x = 0; x < parsers.length; x++) {
                System.out.println("Benching parse with " + (parsers[x] == 0 ? "InputStream" : "ByteArray") + "LexerSource");
                long start = System.nanoTime();
View Full Code Here

            // expected
        }

        // change the thread context to include the class
        SimpleClassLoader simpleLoader = new SimpleClassLoader();
        RubyInstanceConfig config = new RubyInstanceConfig();
        config.setLoader(simpleLoader);
        ruby = Ruby.newInstance(config);

        try {
            ruby.getJRubyClassLoader().loadClass("org.jruby.GiveMeAString");
        } catch (ClassNotFoundException e) {
View Full Code Here

     */
    public void testRedefineClassPerRuntime() throws Exception {
        ClassLoader v1 = new VersionedClassLoader("First");
        ClassLoader v2 = new VersionedClassLoader("Second");

        RubyInstanceConfig config1 = new RubyInstanceConfig();
        config1.setLoader(v1);
        RubyInstanceConfig config2 = new RubyInstanceConfig();
        config2.setLoader(v2);
        Ruby ruby1 = Ruby.newInstance(config1);
        Ruby ruby2 = Ruby.newInstance(config2);

        assertEquals("First", getMessage(ruby1));
        assertEquals("Second", getMessage(ruby2));
View Full Code Here

    /**
     * Tests the {@link org.jruby.runtime.profile.ProfilingServiceLookup} too
     */
    public void testNoProfilingServerAvailableIfProfilingIsDisabled() {
        RubyInstanceConfig config = Ruby.getGlobalRuntime().getInstanceConfig();

        RubyInstanceConfig configOne = new RubyInstanceConfig(config);
        configOne.setProfilingMode(RubyInstanceConfig.ProfilingMode.OFF );

        Ruby ruby = Ruby.newInstance( configOne );

        assertNull(ruby.getProfilingService());
    }
View Full Code Here

    /**
     * Tests the {@link org.jruby.runtime.profile.ProfilingServiceLookup} too
     */
    public void testProfilingServiceLookupWorks() {
        try {
            RubyInstanceConfig config = Ruby.getGlobalRuntime().getInstanceConfig();

            RubyInstanceConfig configOne = new RubyInstanceConfig(config);

            configOne.setProfilingService( TestProfilingService.class.getName() );
            configOne.setProfilingMode(RubyInstanceConfig.ProfilingMode.SERVICE);
            Ruby ruby = Ruby.newInstance( configOne );

            assertNotNull( ruby.getProfiledMethods() );
            assertNotNull( ruby.getProfilingService() );
            assertTrue(ruby.getProfilingService() instanceof TestProfilingService);
View Full Code Here

    private static final String BOOT_SCRIPT = "def fib(a) \n if a.send :<, \n 2 \n a \n else \n fib(a.send :-, 1).send :+, \n fib(a.send :-, 2) \n end \n end";
    private static final String RUN_SCRIPT = "fib(30)";

    public static void main(String[] args) {
        RubyInstanceConfig config = new RubyInstanceConfig();

        RubyInstanceConfig interpConfig = new RubyInstanceConfig();
        config.setCompileMode(RubyInstanceConfig.CompileMode.OFF);

        RubyInstanceConfig tracedConfig = new RubyInstanceConfig();
        config.setCompileMode(RubyInstanceConfig.CompileMode.OFF);
        config.setObjectSpaceEnabled(true);
        RubyInstanceConfig.FULL_TRACE_ENABLED = true;

        runtime = Ruby.newInstance(config);
View Full Code Here

TOP

Related Classes of org.jruby.RubyInstanceConfig$LoadServiceCreator

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.