FreeBASE is a Ruby library that deserves to be better known.
FreeBASE is a plugin management system that automatically handles dependencies and plugin loading and starting. It has an internal databus that it uses, and that your application can use to store data and services. FreeBASE is part of the FreeRIDE project, but can be used independently.
I recently decided to port Redcar onto FreeBASE (ditching my own home-grown plugin system) and I must say that it was the right decision. I’ve been able to rip out an enormous amount of code from the Redcar libs.
For each plugin, you declare the relevant metadata in the plugin.yaml file:
FreeBASE can then calculate the dependencies between plugins (for plugin loading and for starting) and load them in the correct order.
--- !ruby/object:FreeBASE::PluginConfiguration name: documents version: 1.0 autoload: (true) require_path: documents/documents startup_module: Redcar::Plugins::Documents load_dependencies: redcar-core: "*" start_dependencies: redcar-core: "*"
The databus is a little like a filesystem. Here’s what the top two levels look like in Redcar:
Using the FreeBASE databus simplifies things dramatically, because there’s always an obvious place to store information. Each ‘slot’ in the databus can be data, a stack, a queue or a proc. The code to persist subtrees is built-in, and slots can have manager objects and arbitrary attributes.
/system /system/properties /system/shutdown /system/state /log /log/debug /log/info /log/error /plugins /plugins/redcar_core /plugins/arrangements /plugins/textmate_support /plugins/ ... /redcar /redcar/menus /redcar/toolbars /redcar/gtk /redcar/commands /redcar/events /redcar/services /redcar/preferences