/Projects/Modules/JzRuby

JzRuby – exploiting the power of OOP

Ruby is an interpreted general-purpose object-oriented programming language with a steadily growing user base and an excellent support for libraries and 3rd party modules.

Jazzyk Ruby module is a KR module wrapper integrating a Ruby interpreter. With Ruby KR module you can exploit the full strength of object-oriented programming in your Jazzyk programs.

You can imagine the functionality as a running ruby interpreter in an interactive mode (irb) to which at the beginning the code in the initialization notificaton is passed and then each query/update expression are pasted and evaluated. At the end the finalization code is passed to the interpreter and executed. The module is shut-down afterwards.

Author

The JzRuby module was implemented by Bernd Fuhrmann in the context of his diploma thesis at the Department of Informatics of Clausthal University of Technology.

Query interface

Update interface

From the above, it is clear that you can use full-fledged Ruby programs in the code blocks of notifications and query/update operators.

Notifications

Initialization, finalization and cycle module notifications accept any valid Ruby code which is passed to the interpreter which maintains the current state of the Ruby memory space.

Variables

The variable substitution refers to Ruby global variables, i.e. these have to preceded by the dollar sign in the code.

Example

rubytest.jzz:


declare module ruby as ruby
notify ruby on initialize [{
        puts "Ruby launched";
        $myVar = 100
}]
notify ruby on finalize [{puts "Ruby finalized";}]
notify ruby on cycle [{puts "----- Ruby cycle -----";}]

when query ruby [{($myVar>99)}] then {
update ruby [{puts "---- Update ----";}]
}
The execution of the code then yields:
 $ jazzyk -n 5 rubytest.jzz 
 Ruby launched
 ---- Update ----
 ----- Ruby cycle -----
 ---- Update ----
 ----- Ruby cycle -----
 ---- Update ----
 ----- Ruby cycle -----
 ---- Update ----
 ----- Ruby cycle -----
 ---- Update ----
 ----- Ruby cycle -----
 Ruby finalized

Installation

To compile the module code simply execute the standard sequence:

$ ./configure
$ make
$ make install

You might need root rights on your system to install the module properly.

Dependencies

JzRuby module was developed and tested with Boost version 1.34, but should work with latter versions as well.

Ruby KR module can be compiled and used under both -nix/Win32+Cygwin environments. The module was developed and tested to work with Ruby 1.8 interpreter. During compilation (especially under Cygwin) it might happen that the Ruby run-time library won’t be found even though Ruby 1.8 is correctly installed. In that case make a symbolic link in /usr/lib/ to point to the correct library. I.e. if the make script complains about missing “-lruby1.8” file, execute the following command:

$ ln -s /usr/lib/libruby.dll.a /usr/lib/libruby1.8.dll.a

Credits

Bernd Fuhrmann iis the author of the the JzRuby module.