Plug and Play JRuby:
I have recently worked with JRuby to make the Mentawai support for the
language. I wanted to call any Ruby code from my web application as well
be able to have actions fully implemented in Ruby. I also wanted to have
special directory where any Ruby file would be reloaded when modified.
was up for the task and I have decided to offer my solution as a
library so that other people can easily leverage all the power of JRuby
simple plug and play Java class.
The features of my JRubyInterpreter class are:
- Simple API to call ruby methods on any Ruby object from Java
- JRubyWrapper for making ruby method calls even easier
- Auto-reload any ruby file from the loadpath
- Load any ruby file from the classpath (even from jars) with the
- Get a singleton instance of the JRubyInterpreter anywhere in your code
with the JRubyInterpreter.getInstance() method
- Support all JRuby environment variables and provide defaults for them.
JRUBY_OPTS for -rubygems and -Ku , JRUBY_SHELL, JRUBY_SCRIPT, JRUBY_LIB
- Windows and Linux support
Code speaks better than 1000 words, so here are an example:
Please feel free to reply with comments, suggestions and improvements.
-Sergio Oliveira Jr.