Here you can find the source of listGems(ScriptEngine jruby)
Parameter | Description |
---|---|
jruby | The jruby scripting engine |
Parameter | Description |
---|---|
ScriptException | Thrown if their are any ruby problems |
@SuppressWarnings("nls") public static void listGems(ScriptEngine jruby) throws ScriptException
//package com.java2s; /*/*from w ww . ja v a 2s . co m*/ * Copyright (C) 2008-2011 John-Paul.Stanford <dev@stanwood.org.uk> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import javax.script.ScriptEngine; import javax.script.ScriptException; public class Main { /** * Used to print a list of install gems to stdout * @param jruby The jruby scripting engine * @throws ScriptException Thrown if their are any ruby problems */ @SuppressWarnings("nls") public static void listGems(ScriptEngine jruby) throws ScriptException { StringBuilder script = new StringBuilder(); script.append("require 'rubygems'\n"); script.append("require 'rubygems/gem_runner'\n"); script.append("Gem::GemRunner.new.run [\"list\"]\n"); jruby.eval(script.toString()); } }