Friday 27 July 2012

Sharing Ruby Programs

I hope that one theme that runs through these various blog pieces is a preference for simple solutions.

I wondered in another piece why it was necessary to go to the trouble of writing the Jquery-Rails gem just to distribute a few Javascript files?

I have often felt that it would be nice to be able to give someone else a copy of one of my Ruby programs. But it was always very obvious that the people I would be likely to give a program to would have neither the interest nor the expertise to get the MRI Ruby system working so that they could use my program.

JRuby changes all that.

Of course JRuby only works on a computer with the Java runtime system. But most PCs have it already and, if not, installing it is straightforward - unlike installing MRI Ruby and the Gems necessary for your project.

If you want to distribute your JRuby project (big or small) all you need to do is include the JRuby system within it and a shell script or batch file that sets the PATH variable and starts the application. And if you give a copy of the whole project to someone else all they have to do is load it onto their PC and double-click the script/batch file.

For a simple project the directory structure might look like this

.
├── jruby-1.7.0.preview1/
├── helloworld.rb
└── LocalJRubyTerminal.sh*

Or for a Ruby-on-Rails project it might look like this

.
├── app/
├── config/
├── db/
~
├── jruby-1.7.0.preview1/
~
├── public/
├── script/
~
├── config.ru
~
├── LocalJRubyTerminal.sh*
├── Rakefile
└── README

Unfortunately if you go looking for internet advice about making your JRuby app shareable you will find any number of complex solutions (Warbler, Rawr etc) and (as far as I can see) no simple solutions that take advantage of the Java runtime system.

No comments:

Post a Comment