Get Version



ContextR is a library supporting context-oriented programming.

Version 1.0.2

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.

      /      \
    MIT     Ruby's terms
            /          \
          GPL      Ruby license

Version 1.0.1

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.

Version 1.0.0

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 website.

Version 0.1.9

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

Version 0.1.1

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 representing them. ContextR::layers gives all already defined layers, but they are not necessarily active or have been.

Version 0.1.0

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

The basics

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 contextr gem

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.


Other resources

COP related

ContextR related


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

Read the 8 steps for fixing other people’s code and for section 8z: Email the project owner, use the e-mail address below.

The repository is browseable via github. To get a copy to your machine use:

git clone 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