Sha256: 8999e3a7fe60d5284f4ebaca3dbbd229c30327b2874644cfa4a29898e254d4d5

Contents?: true

Size: 1.68 KB

Versions: 11

Compression:

Stored size: 1.68 KB

Contents

package com.gsamokovarov.skiptrace;

import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyModule;
import org.jruby.RubyClass;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.builtin.InstanceVariables;
import org.jruby.anno.JRubyMethod;

public class JRubyIntegration {
    public static void setup(Ruby runtime) {
        RubyModule skiptrace = runtime.defineModule("Skiptrace");
        skiptrace.defineAnnotatedMethods(SkiptraceMethods.class);

        RubyClass exception = runtime.getException();
        exception.defineAnnotatedMethods(ExceptionExtensionMethods.class);

        IRubyObject verbose = runtime.getVerbose();
        try {
            runtime.setVerbose(runtime.getNil());
            runtime.addEventHook(new SetExceptionBindingsEventHook());
        } finally {
            runtime.setVerbose(verbose);
        }
    }

    public static class SkiptraceMethods {
        @JRubyMethod(name = "current_bindings", meta = true)
        public static IRubyObject currentBindings(ThreadContext context, IRubyObject self) {
            return RubyBindingsCollector.collectCurrentFor(context);
        }
    }

    public static class ExceptionExtensionMethods {
        @JRubyMethod
        public static IRubyObject bindings(ThreadContext context, IRubyObject self) {
            InstanceVariables instanceVariables = self.getInstanceVariables();

            IRubyObject bindings = instanceVariables.getInstanceVariable("@bindings");
            if (bindings != null && !bindings.isNil()) {
                return bindings;
            }

            return RubyArray.newArray(context.getRuntime());
        }
    }
}

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/bindex-0.8.1/ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/bindex-0.8.1/ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/bindex-0.8.1/ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
bindex-0.8.1 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
skiptrace-0.8.1 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
skiptrace-0.8.0 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
bindex-0.8.0 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
bindex-0.7.0 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
skiptrace-0.7.0 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
bindex-0.6.0 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java
skiptrace-0.6.0 ext/skiptrace/com/gsamokovarov/skiptrace/JRubyIntegration.java