Package org.jruby

Examples of org.jruby.RubyInstanceConfig$LoadServiceCreator


        }
    }
   
    public void testPrintErrorShouldPrintErrorMessageAndStacktraceWhenBacktraceIsPresent() {
        final ByteArrayOutputStream err = new ByteArrayOutputStream();
        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
            setTraceType(TraceType.traceTypeFor("mri"));
        }};
        Ruby ruby = Ruby.newInstance(config);
        RubyException exception = (RubyException)runtime.getClass("NameError").newInstance(ruby.getCurrentContext(), new IRubyObject[]{ruby.newString("A message")},  Block.NULL_BLOCK);
View Full Code Here


    }
   
    public void testPrintErrorShouldOnlyPrintErrorMessageWhenBacktraceIsNil() {
        final ByteArrayOutputStream err = new ByteArrayOutputStream();
        // use MRI formatting, since JRuby formatting is a bit different
        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
            setTraceType(TraceType.traceTypeFor("mri"));
        }};
        Ruby ruby = Ruby.newInstance(config);
        RubyException exception = (RubyException)runtime.getClass("NameError").newInstance(ruby.getCurrentContext(), new IRubyObject[]{ruby.newString("A message")},  Block.NULL_BLOCK);
View Full Code Here

        public void report(ProfileCollection collector) {

            if(!(collector instanceof ProfileData))
                throw new IllegalArgumentException( "Given collector must be an instance of " + ProfileData.class.getName() + "." );

            RubyInstanceConfig config = getConfig();
            ProfileData   profileData = (ProfileData) collector;
            ProfileOutput      output = config.getProfileOutput();

            ProfilePrinter profilePrinter = ProfilePrinter.newPrinter( config.getProfilingMode(), profileData );
            if (profilePrinter != null) {
                output.printProfile(profilePrinter);
            } else {
                getRuntime().getOut().println("\nno printer for profile mode: " + config.getProfilingMode() + " !");
            }
        }
View Full Code Here

    private RubyInstanceConfig config;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        config = new RubyInstanceConfig();
    }
View Full Code Here

        fail();
        return null;
    }

    private RootNode parse(String source) {
        final RubyInstanceConfig instanceConfiguration = new RubyInstanceConfig();
        instanceConfiguration.setDisableGems(true);
        final Ruby ruby = Ruby.newInstance(instanceConfiguration);
        final ParserConfiguration parserConfiguration = new org.jruby.parser.ParserConfiguration(ruby, 0, false, true, true);
        final StaticScope staticScope = ruby.getStaticScopeFactory().newLocalScope(null);
        final Parser parser = new org.jruby.parser.Parser(ruby);
        return (RootNode) parser.parse("test", source.getBytes(), new ManyVarsDynamicScope(staticScope), parserConfiguration);
View Full Code Here

     *
     * @param loadPaths to specify where to look for Ruby modules.
     * @return an instance
     */
    public static Ruby initialize(List loadPaths) {
        return initialize(loadPaths, new RubyInstanceConfig());
    }
View Full Code Here

    public ConcurrentLocalContextProvider(LocalVariableBehavior behavior, boolean lazy) {
        // To save startup time, Ruby runtime instantiation should be delayed as mush as possible
        // so, don't create runtime here.
        if (Ruby.isGlobalRuntimeReady()) config = Ruby.getGlobalRuntime().getInstanceConfig();
        else config = new RubyInstanceConfig();
        this.behavior = behavior;
        this.lazy = lazy;
    }
View Full Code Here

     *
     * @param container ScriptingContainer to be set configurations.
     */
    public static void setConfiguration(ScriptingContainer container) {
        LocalContextProvider provider = container.getProvider();
        RubyInstanceConfig config = provider.getRubyInstanceConfig();
        String s = SafePropertyAccessor.getProperty(PropertyName.COMPILEMODE.toString());
        if (s != null) {
            if ("jit".equalsIgnoreCase(s)) {
                config.setCompileMode(CompileMode.JIT);
            } else if ("force".equalsIgnoreCase(s)) {
                config.setCompileMode(CompileMode.FORCE);
            } else {
                config.setCompileMode(CompileMode.OFF);
            }
        }
    }
View Full Code Here

    }

    public int run(NGContext context) {
        context.assertLoopbackClient();

        RubyInstanceConfig config = new RubyInstanceConfig();
        Main main = new Main(config);
       
        config.setCurrentDirectory(context.getWorkingDirectory());
        config.setEnvironment(context.getEnv());

        return main.run(context.getArgs()).getStatus();
    }
View Full Code Here

        // preboot actual runtime
        Ruby.clearGlobalRuntime();
        File dripMain = new File(JRUBY_DRIP_PREBOOT_FILE);

        RubyInstanceConfig config = new RubyInstanceConfig();
        ruby = Ruby.newInstance(config);

        if (dripMain.exists()) {
            FileInputStream fis = new FileInputStream(dripMain);
            try {
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.