本文整理汇总了Java中org.jruby.embed.ScriptingContainer.parse方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptingContainer.parse方法的具体用法?Java ScriptingContainer.parse怎么用?Java ScriptingContainer.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jruby.embed.ScriptingContainer
的用法示例。
在下文中一共展示了ScriptingContainer.parse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeJRubyRuntime
import org.jruby.embed.ScriptingContainer; //导入方法依赖的package包/类
private void initializeJRubyRuntime() {
container = new ScriptingContainer(org.jruby.embed.LocalContextScope.SINGLETHREAD);
if (jobConf != null) {
container.getLoadPaths().add(jobConf.get(CONF_JRB_LOAD_PATH));
}
if (rbScriptParam.startsWith(MODE_METHOD_MARK)) {
mode = MODE.METHOD;
evaluateMethod = rbScriptParam.substring(1);
container.setAttribute(AttributeName.SHARING_VARIABLES, false);
receiver = container.runScriptlet(rbEnvScript);
} else {
mode = MODE.EVAL;
evalUnit = container.parse(rbScriptParam);
}
LOG.info("initialized JRuby runtime (" +
container.getCompatVersion() + ", " +
container.getCompileMode()
+ ")");
}
示例2: setup
import org.jruby.embed.ScriptingContainer; //导入方法依赖的package包/类
@Override
public void setup(OperatorContext context)
{
sc = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
for (String s : setupScripts) {
EvalUnit unit = sc.parse(s);
unit.run();
}
if (type == Type.EVAL) {
unit = sc.parse(script);
}
}
示例3: loadConfiguration
import org.jruby.embed.ScriptingContainer; //导入方法依赖的package包/类
/**
* Load the Haml viewer configuration for the view.
*
* @param configuration The configuration object
*/
public void loadConfiguration(Configuration configuration)
throws ConfigurationException {
List<String> loadPaths = new ArrayList<String>();
// SINGLETHREAD is not threadsafe: http://www.ruby-forum.com/topic/206056#new
container = new ScriptingContainer(LocalContextScope.THREADSAFE);
scriptingContainerConfiguration = configuration;
RubyInstanceConfig config = container.getProvider().getRubyInstanceConfig();
if (scriptingContainerConfiguration != null) {
jrubyhome = scriptingContainerConfiguration.getChildValue("jruby_home");
if (jrubyhome != null) {
config.setJRubyHome(jrubyhome);
loadPaths.add(jrubyhome);
}
String userHamlScript = scriptingContainerConfiguration.getChildValue("haml");
if (userHamlScript != null) {
haml_rb = userHamlScript; //just a bit of inversion of control
}
}
haml_rb_unit = container.parse(haml_rb);
log.info("haml enabled ... have fun!");
}
示例4: getScript
import org.jruby.embed.ScriptingContainer; //导入方法依赖的package包/类
public JavaEmbedUtils.EvalUnit getScript() throws FileNotFoundException {
if (this.unit == null) {
if (!this.configFile.exists()) {
throw new FileNotFoundException("Configuration file does not exist");
}
ScriptingContainer scriptingContainer = new ScriptingContainer(
LocalContextScope.THREADSAFE,
LocalVariableBehavior.PERSISTENT);
scriptingContainer.setOutput(new PrintStream(new NullOutputStream()));
StringBuilder script = new StringBuilder()
.append("require 'compass'\n")
.append("require 'compass/sass_compiler'\n")
.append("Compass.reset_configuration!\n")
.append("Compass.add_project_configuration configLocation\n")
// remove color codes since they cannot be proceeded correctly by IDE consoles
.append("Compass.configuration.color_output = false\n")
.append("Compass.configure_sass_plugin!\n")
.append("Compass.configuration.on_stylesheet_saved { |filename| callback_logger.onStylesheetSaved(filename) }\n")
.append("Compass.configuration.on_stylesheet_error { |filename, message| callback_logger.onStylesheetError(filename, message) }\n")
.append("Compass.configuration.on_sprite_saved { |filename| callback_logger.onSpriteSaved(filename) }\n")
.append("Dir.chdir(File.dirname(configLocation)) do\n")
.append(" Compass.sass_compiler.compile!\n")
.append("end\n");
scriptingContainer.put("configLocation", this.configFile.getAbsolutePath().replaceAll("\\\\", "/"));
scriptingContainer.put("callback_logger", callbackLogger);
this.unit = scriptingContainer.parse(script.toString());
}
return this.unit;
}