ruby-RPP: A Ruby Preprocessor

What is it ?

ruby-rpp, rpp or in full "The Ruby Preprocessor", is a pure ruby implementation of a generic on-the-fly preprocessor for ruby. It is intended to be extended by a collection of specific preprocessors. Each file that requires such a preprocessor only needs to litterally require the specific preprocessor at the top-level of the file(s) that need(s) preprocessing.

What kind of preprocessors are available ?

Currently there is only one preprocessor implemented: rpp/type-annotations.


rpp/type-annotations

Introduction

rpp/type-annotations is a preprocessor that allows one to write type annotations within regular ruby syntax (i.e. in a structured manner as opposed to an unstructured manner (comments)). The type annotations do not enforce anything, the goal is to add more structured information to a ruby file. Ducktyping is still honored, but it is the authors strong believe that the extra type annotations add to the readability of ruby code.

Example

So what does this all look like ? Well, consider the following screenshot. You can see the inline type annotations right away.

example of what ruby with type-annotations look like

Convinced and want to know how simple it is to use ? Read on...

Installation

go to your favorite RUBYLIB/RUBYPATH and check out the following modules from cvs:

  1. rpp
  2. util
You can optionally also check out the module: extras. It contains syntax definition files etc..

If you don't want to use CVS directly, you can get an automatically generate tarball here. Please copy the directories ruby-rpp/rpp and ruby-rpp/util to a directory in your RUBYLIB/RUBYPATH.

Usage

It's fairly simple to use rpp/type-annotations. Just add the following two lines at the top of each file in which you want to use type annotations.

require 'rpp/type-annotations'
__END__
That's all. There is nothing more to it, you can start type-annotating your ruby code right away.

Licensing

The Ruby Preprocessor and all its derived work is available under the GNU Public License. The following license excerpt holds for all files released by this project:

This file 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 2 of the License, or (at your option) any later version.

This file 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 file; if not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Acknowledgements

The Ruby Preprocessor's core code is based on the wonderful silliness called hyphen-ruby by Daniel Brockman, you can find his original work here

Last modified: Sun Oct 23 20:32:08 UTC 2005