Package org.jruby.embed

Examples of org.jruby.embed.ScriptingContainer


        return jRubyAsciidoctor;
    }

    private static Asciidoctor createJRubyAsciidoctorInstance(ClassLoader classloader) {

        ScriptingContainer container = new ScriptingContainer();
        container.setClassLoader(classloader);
        Ruby rubyRuntime = container.getProvider().getRuntime();

        JRubyRuntimeContext.set(rubyRuntime);

        JRubyAsciidoctorModuleFactory jRubyAsciidoctorModuleFactory = new JRubyAsciidoctorModuleFactory(rubyRuntime);
View Full Code Here


   *
   * We also register xstream mappers for JRuby objects so that they
   * can be persisted along with other objects in Jenkins.
   */
  public RubyPlugin() {
    this.ruby = new ScriptingContainer(LocalContextScope.THREADSAFE);
    this.ruby.setClassLoader(this.getClass().getClassLoader());
    this.ruby.getLoadPaths().add(0, this.getClass().getResource("support").getPath());
    this.ruby.getLoadPaths().add(this.getClass().getResource("jenkins-plugins/lib").getPath());
    this.ruby.getLoadPaths().add(this.getClass().getResource(".").getPath());
    this.extensions = new ArrayList<ExtensionComponent>();
View Full Code Here

    @Override
    public void initialize(BSFManager manager, String language, Vector someDeclaredBeans) throws BSFException {
        super.initialize(manager, language, someDeclaredBeans);
        LocalContextScope scope = SystemPropertyCatcher.getScope(LocalContextScope.SINGLETON);
        LocalVariableBehavior behavior = LocalVariableBehavior.BSF;
        container = new ScriptingContainer(scope, behavior);
        SystemPropertyCatcher.setConfiguration(container);
        //container.getProvider().setLoadPaths(getClassPath(manager));
        if (!SystemPropertyCatcher.isRuby19(language)) {
            container.getProvider().getRubyInstanceConfig().setCompatVersion(CompatVersion.RUBY1_8);
        }
View Full Code Here

     * <p/>
     * We also register xstream mappers for JRuby objects so that they
     * can be persisted along with other objects in Jenkins.
     */
    public ScriptingContainerHolder() {
        this.ruby = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
        this.ruby.setCompatVersion(CompatVersion.RUBY1_9);
        this.ruby.setClassLoader(Jenkins.getInstance().pluginManager.uberClassLoader);
    }
View Full Code Here

            path[1] = path[1].replace(System.getProperty("user.dir"),"");//deletes path up to project
            path[1] = path[1].replace(path[0],"");//deletes name from path
            path[0] = path[0].replace(".class", "");//deletes the .class extension from the name
            path[1] = path[1].replaceFirst("/", "");//deletes first instance of "/" for Ruby code to work
        }try {
          ScriptingContainer container = new ScriptingContainer();
          container.setArgv(path);//sets ARGV
          container.runScriptlet(new BufferedReader(new FileReader("driver.rb")), "driver.rb");
    } catch (FileNotFoundException e) {
      System.out.println("No File chosen or file does not exist");
    } catch (NullPointerException npe)
    {
   
View Full Code Here

      throw new RuntimeException(e);
    }
  }

  public JRubyContainerAndReceiver jruby(String file) {
    ScriptingContainer container = new ScriptingContainer();
    String filename = "snippets/jruby/" + file + ".rb";
    return new JRubyContainerAndReceiver(container,
        container.runScriptlet(CodeLoader.class.getResourceAsStream("/" + filename), filename));
  }
View Full Code Here

  }

  @Test
  public void rubyCanDecodeHmacSignedToken() throws Exception {
    Jwt jwt = JwtHelper.encode(TEST_CLAIMS, hmac);
    ScriptingContainer container = new ScriptingContainer();
    container.put("@token", jwt.getEncoded());
    container.put("@claims", "");
    String script =
        "require \"jwt\"\n" +
        "@claims = JWT.decode(@token, \"secret\", \"HS256\").to_json\n" +
        "puts @claims";
    container.runScriptlet(script);
    assertEquals(TEST_CLAIMS, container.get("@claims"));
  }
View Full Code Here

    assertEquals(TEST_CLAIMS, container.get("@claims"));
  }

  @Test
  public void canDecodeRubyHmacSignedToken() throws Exception {
    ScriptingContainer container = new ScriptingContainer();
    container.put("@token", "xxx");
    String script =
        "require \"jwt\"\n" +
        "@token = JWT.encode({\"some\" => \"payload\"}, \"secret\", \"HS256\")\n" +
        "puts @token";
    container.runScriptlet(script);
    String token = (String) container.get("@token");
    Jwt jwt = JwtHelper.decodeAndVerify(token, hmac);
    assertEquals(TEST_CLAIMS, jwt.getClaims());
    container.terminate();
  }
View Full Code Here

        try {
          String script =
              "require \"jwt\"\n" +
              "require \"bouncy-castle-java\"\n" +
              "require \"openssl\"";
          ScriptingContainer container = new ScriptingContainer();
          container.runScriptlet(script);
          setupOk = true;
        }
        catch (Exception e) {
          System.out.println("jruby.home not set or JWT gem not available. JWT ruby integration tests will be skipped" + e.getMessage());
        }
View Full Code Here

          }
       
        @Override
        public void init()
          {
          container = new ScriptingContainer();
          container.setCompileMode(CompileMode.FORCE);
          container.put("$numPrimes", 0L);
          container.setAttribute("$num", num);
          ruby = readFileAsString(file);
         
View Full Code Here

TOP

Related Classes of org.jruby.embed.ScriptingContainer

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.