Package org.jruby.embed

Examples of org.jruby.embed.EmbedEvalUnit


public class ConstantCompilationTest extends TestCase{
    public void testConstantCompilation(){
        ScriptingContainer c = new ScriptingContainer(LocalContextScope.SINGLETHREAD, LocalVariableBehavior.PERSISTENT);
        c.setCompatVersion(CompatVersion.RUBY1_8);
        c.setCompileMode(CompileMode.FORCE);
        EmbedEvalUnit unit = c.parse("RUBY_VERSION", 0);
        assertEquals("1.8.7", unit.run().toString());
    }
View Full Code Here


            throw new NullPointerException("either script or context is null");
        }
        container.setScriptFilename(Utils.getFilename(context));
        try {
            Utils.preEval(container, context);
            EmbedEvalUnit unit = container.parse(script, Utils.getLineNumber(context));
            IRubyObject ret = unit.run();
            return JavaEmbedUtils.rubyToJava(ret);
        } catch (Exception e) {
            throw wrapException(e);
        } finally {
            Utils.postEval(container, context);
View Full Code Here

            throw new NullPointerException("either reader or context is null");
        }
        String filename = Utils.getFilename(context);
        try {
            Utils.preEval(container, context);
            EmbedEvalUnit unit = container.parse(reader, filename, Utils.getLineNumber(context));
            IRubyObject ret = unit.run();
            return JavaEmbedUtils.rubyToJava(ret);
        } catch (Exception e) {
            throw wrapException(e);
        } finally {
            Utils.postEval(container, context);
View Full Code Here

        try {
            if (Utils.isClearVariablesOn(context)) {
                container.clear();
            }
            Utils.preEval(container, context);
            EmbedEvalUnit unit = container.parse(script, Utils.getLineNumber(context));
            IRubyObject ret = unit.run();
            return JavaEmbedUtils.rubyToJava(ret);
        } catch (Exception e) {
            throw wrapException(e);
        } finally {
            Utils.postEval(container, context);
View Full Code Here

        try {
            if (Utils.isClearVariablesOn(context)) {
                container.clear();
            }
            Utils.preEval(container, context);
            EmbedEvalUnit unit = container.parse(reader, filename, Utils.getLineNumber(context));
            IRubyObject ret = unit.run();
            return JavaEmbedUtils.rubyToJava(ret);
        } catch (Exception e) {
            throw wrapException(e);
        } finally {
            Utils.postEval(container, context);
View Full Code Here

        try {
            if (Utils.isClearVariablesOn(context)) {
                container.clear();
            }
            Utils.preEval(container, context);
            EmbedEvalUnit unit = container.parse(script, Utils.getLineNumber(context));
            IRubyObject ret = unit.run();
            return JavaEmbedUtils.rubyToJava(ret);
        } catch (Exception e) {
            throw wrapException(e);
        } finally {
            Utils.postEval(container, context);
View Full Code Here

        try {
            if (Utils.isClearVariablesOn(context)) {
                container.clear();
            }
            Utils.preEval(container, context);
            EmbedEvalUnit unit = container.parse(reader, filename, Utils.getLineNumber(context));
            IRubyObject ret = unit.run();
            return JavaEmbedUtils.rubyToJava(ret);
        } catch (Exception e) {
            throw wrapException(e);
        } finally {
            Utils.postEval(container, context);
View Full Code Here

        ScriptingContainer runtime = setupScriptingContainer(file);
        try {
            // run init script
            runResourceScript(runtime, initScript);

            final EmbedEvalUnit eval = runtime.parse(PathType.RELATIVE, file.getPath());
            /*IRubyObject res =*/ eval.run();

            // create plugin description
            final PluginDescriptionFile description = getDescriptionFile(runtime);
            if (description == null)
                return null;    // silent fail if the script doesn't contain a plugin description
View Full Code Here

        ScriptingContainer runtime = setupScriptingContainer(file);
        try {
            // run init script
            runResourceScript(runtime, initScript);

            final EmbedEvalUnit eval = runtime.parse(PathType.RELATIVE, file.getPath());
            /*IRubyObject res =*/ eval.run();

            return getDescriptionFile(runtime);

        } catch (IOException e) {
            throw new InvalidDescriptionException(e);
View Full Code Here

TOP

Related Classes of org.jruby.embed.EmbedEvalUnit

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.