ContextR is a library supporting context-oriented programming.
ContextR is now released under a triple license – first of all under an MIT-style license and secondly under the same terms as Ruby, which is again licensed under the GPL or the Ruby license.
ContextR / \ MIT Ruby's terms / \ GPL Ruby license
This version includes the latest changes, that were introduced when finishing the thesis. Nothing, that changes the usage, performance or API, just minor refactorings inside the library.
Along with my Master’s thesis ending and my lightning talk at euruko
2008, the first stable release of ContextR will be
published. To reflect its status the version number reaches 1.0. You may find
documentation and examples in the
test directory or on in your Browser on
This is a review release. Again, lots of things changed, but I think to the better. There will be more coverage with the 0.2.0. Until then, have a look at the shiny new online documentation
In this release we have added code examples, that also act as tests. See this blog article for more information. This brought vast feature coverage with test.
An RSpec was added to allow even more test coverage.
Object#extend allows definition of class side context dependent behaviour.
There have been minor changes to the reflection API. To fetch the currently
active layers use
ContextR::active_layers and you will get an array of symbols
ContextR::layers gives all already defined layers, but they
are not necessarily active or have been.
This is the first release of ContextR after the 0.0.3 release. Since then a full redesign took place. The API changed entirely so make sure to not use this release with older code.
We think, that the new API is more powerful and allows better code to be written with ContextR. Unfortunately it has some issues as well, but we consider them as less relevant than the other way around. If you have any problems or question concerning these changes, feel free to use the new mailing list – any hint is appreciated
sudo gem install contextr
In your code use
require 'rubygems' require 'contextr'
and ContextR will be ready to use. ContextR should work on Ruby 1.8 and JRuby.
To get ContextR running, you won’t need anything but
rubygems and the
To run all tests and documentation generation you will need the following gems:
Demonstration of usage
See the online documentation for usage examples and some meta information or have a look at the other resources below.
- COP at SWA at the HPI More information on other context-oriented programming libraries as well as papers and theoretical work can be found at the COP page of Prof. Hirschfeld’s software architecture group at the HPI
If context-oriented programming does not fit your needs to handle your cross-cutting concerns, have a look at aspect-oriented programming. There is a feature rich implementation for Ruby named aquarium. Alternatively you may find interest in feature-oriented programming. If all that does not help, feel free to drop me a note and tell me, what you are trying to achieve.
How to submit patches
The repository is browseable via github. To get a copy to your machine use:
git clone git://github.com/schmidt/contextr.git
This code is free to use under the terms of the Ruby license.
Comments are welcome. Send an email to Gregor Schmidt.
28th April 2008
Theme extended from Paul Battley