A Ruby Binding


The Linux Registry [http://registry.sourceforge.net] is a toolkit that provides a programmatic registry for Linux applications. The term "registry" is taken from Windows, but the idea dates back to at least NeXTSTEP, which had a similar concept. The idea is that persistent properties are managed by a simple library and are available to applications for setting configuration data in a consistent manner. Read the main Linux Registry page for more in-depth reasons as to why this is a good thing.

This project, in particular, provides a Ruby binding for the Linux Registry, providing an easy API for accessing registry variables.


The source repository is a Subversion repository.

The main project page is here.


here are six methods currently implemented, which should be enough for average use:

  • open() Opens the registry. If passed a closure, this functions like File::open, in that the registry is automatically closed at the end of the proc.

  • close() Closes the registry.

  • get( KEYNAME ) Gets the value of a key

  • set( KEYNAME, KEYVALUE ) Sets a key

  • keys( BASE=nil ) Returns an Array of Strings which are the names of all of the keys in the registry. The optional argument provides a filter equivalent to /^BASE/

  • remove( KEYNAME ) Removes a key from the registry.

Example 1

Registry::open() {
  Registry::set( "user/lib/registry/version", "0.2.2" )
  p Registry::get( "user/lib/registry/version" )
  p Registry::keys
  Registry::remove( "user/lib/registry/version" )

This generates:

["system", "user:ser", "user:ser/lib/registry/version"]

Note that if you use closures, you don't have to explicitly close the registry. You can also call it like this:

Example 2
v = Registry::get( "system/sw/apache2/BaseDir" )


To use registry, have The Linux Registry and Ruby installed. Download the distribution and unpack it. Change into the project directory and run:

% ruby extconf.rb
% make
% sudo make install       # or similar

Tests can be run without having registry installed, as long as registry.so is in the same directory (or somewhere in the $: path) where you're running your script.


  • The Ruby binding doesn't deal with non-string data yet. Soon, Grasshopper.

  • Much of the Linux Registry API is missing. For the most part, this doesn't matter, since you can do almost everything with what is provided. However, the API dealing with permissions will be necessary.

  • The API for getting a list of keys should be expanded upon, to support filtering to the extent that registryGetChildKeys() supports.