Package org.jruby

Examples of org.jruby.RubyIO$POpenTuple


        runtime.getGlobalVariables().alias("$deferr", "$stderr");
    }
   
    private static RubyIO getRubyIO(Ruby runtime, Writer writer) throws IOException, BadDescriptorException {
        PrintStream pstream = new PrintStream(new WriterOutputStream(writer), true);
        RubyIO io = new RubyIO(runtime, pstream, false);
        io.getOpenFile().getMainStreamSafe().setSync(true);
        io.getOpenFile().getMainStreamSafe().fflush();
        return io;
    }
View Full Code Here


            }
        }
        map.put(AttributeName.READER, reader);
        InputStream istream = new ReaderInputStream(reader);
        Ruby runtime = provider.getRuntime();
        RubyIO io = new RubyIO(runtime, istream);
        io.getOpenFile().getMainStream().setSync(true);
        runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", io));
        runtime.getObject().storeConstant("STDIN", io);
    }
View Full Code Here

    private void setOutputStream(PrintStream pstream) {
        if (pstream == null) {
            return;
        }
        Ruby runtime = provider.getRuntime();
        RubyIO io = new RubyIO(runtime, pstream);
        io.getOpenFile().getMainStream().setSync(true);
        runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io));
        runtime.getObject().storeConstant("STDOUT", io);
        runtime.getGlobalVariables().alias("$>", "$stdout");
        runtime.getGlobalVariables().alias("$defout", "$stdout");
    }
View Full Code Here

    private void setErrorStream(PrintStream error) {
        if (error == null) {
            return;
        }
        Ruby runtime = provider.getRuntime();
        RubyIO io = new RubyIO(runtime, error);
        io.getOpenFile().getMainStream().setSync(true);
        runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io));
        runtime.getObject().storeConstant("STDERR", io);
        runtime.getGlobalVariables().alias("$deferr", "$stderr");
    }
View Full Code Here

        // Don'
        Ruby runtime = container.getProvider().getRuntime();
        GlobalVariables gvars = runtime.getGlobalVariables();
        IRubyObject orig = gvars.get("$stderr");
        // Todo: cache this or find a better way of supressing output...
        gvars.set("$stderr", new RubyIO(runtime, new ByteArrayOutputStream()));
        try {
            return container.parse(scr, lineNumbers);
        } catch (ParseFailedException e) {
            /**/
        } catch (Exception e) {
View Full Code Here

        // Suppress output...
        Ruby runtime = container.getProvider().getRuntime();
        GlobalVariables gvars = runtime.getGlobalVariables();
        IRubyObject orig = gvars.get("$stderr");
        // Todo: cache this or find a better way of supressing output...
        gvars.set("$stderr", new RubyIO(runtime, new ByteArrayOutputStream()));
        try {
            container.parse(scr, lineNumbers);
        } catch (ParseFailedException e) {
            ScriptException se = parseRubyParseException(e);
View Full Code Here

     * @see #hookIntoRuntime(Ruby)
     */
    public void hookIntoRuntimeWithStreams(final Ruby runtime) {
        hookIntoRuntime(runtime);

        RubyIO in = new RubyIO(runtime, getInputStream());
        runtime.getGlobalVariables().set("$stdin", in);

        RubyIO out = new RubyIO(runtime, getOutputStream());
        runtime.getGlobalVariables().set("$stdout", out);
        runtime.getGlobalVariables().set("$stderr", out);
    }
View Full Code Here

                readArray = null;
            } else {
                readIOs = new RubyIO[readSize];
                Map<Character,Integer> attachment = new HashMap<Character,Integer>(1);
                for (int i = 0; i < readSize; i++) {
                    RubyIO ioObj = saveReadIO(i, context);
                    saveReadBlocking(ioObj, i);
                    saveBufferedRead(ioObj, i);                   
                    attachment.clear();
                    attachment.put('r', i);
                    trySelectRead(context, attachment, ioObj);
View Full Code Here

        }
    }

    private RubyIO saveReadIO(int i, ThreadContext context) {
        IRubyObject obj = readArray.eltOk(i);
        RubyIO ioObj = RubyIO.convertToIO(context, obj);
        readIOs[i] = ioObj;
        return ioObj;
    }
View Full Code Here

                writeArray = null;
            } else {
                writeIOs = new RubyIO[writeSize];
                Map<Character,Integer> attachment = new HashMap<Character,Integer>(1);
                for (int i = 0; i < writeSize; i++) {
                    RubyIO ioObj = saveWriteIO(i, context);
                    saveWriteBlocking(ioObj, i);
                    attachment.clear();                   
                    attachment.put('w', i);
                    trySelectWrite(context, attachment, ioObj);
                }
View Full Code Here

TOP

Related Classes of org.jruby.RubyIO$POpenTuple

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.