ReferenceBook
A multi-context configuration library and DSL.
ReferenceBook provides an easy interface to define, validate and query multi-context configuration data.
What does multi-context mean?
Any setting that should be static and that exist in different alternative versions.
Usage
TODO: Write usage instructions here
Examples
Lots are available in the repo.
Features/Problems
- requires Ruby >= 2.0.0
- simple configuration DSL, with validations
- configuration data exists as frozen objects, not namespaced constants
- library and books metaphor
- easy and flexible query interface
Rubies
ReferenceBook requires a Ruby patch level >= 2.0
.
It doesn't use any 2-only syntax features, but it does rely on some core classes' methods that only appeared with MRI 2.0.0.
MRI: supported, tested with 2.0 and 2.1.
JRuby: tested in 2.0 mode (JRUBY_OPTS=--2.0 rake test
).
Rubinius: not supported, even in 2.1 mode its standard library classes seem to expose a 1.9 interface.
Tests
rake test
To Do
- add support for different libraries, each with an enforced book structure
- make it work with Ruby 1.9.3 (involves implementing methods that at the moment are provided by core classes).
- memoize results of
pluck
andhash_pluck
- implement
library_key
aliases, so that books can be retrieved with strings. Library keys have to be symbols, because they are used to define the accessor methods
Installation
Add this line to your application's Gemfile:
gem 'reference_book'
And then execute:
$ bundle
Or install it yourself as:
$ gem install reference_book
Contributing
- Fork it ( https://github.com/[my-github-username]/reference_book/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request