Configatron: Simple, Persistent Configs for your Ruby App(s)
Configatron is a new Ruby library that makes it easy to have persistently accessible configuration data available through your Ruby application. It bears some similarities to the Rails pluginSimpleConfig, but being distributed as a gem, is suitable for non-Rails applications. To install:
gem install configatron
Once configatron is installed, the following code will get things going:
configatron do |config| config.app_name = "My Awesomely Jazzy App" config.database_url = "postgres://localhost/somedb" # etc... end
And then you can access these configuration variables throughout your application, like so:
configatron.app_name # => "My Awesomely Jazzy App" configatron.database_url # => "postgres://localhost/somedb"
Note that this only gives a very cursory look at what Configatron offers, however, as it has many other features - including namespacing and nested configurations.
Configatron comes from Mark Bates, creator of the Mack Web application framework.
Post supported by thoughtbot training — thoughtbot is a five year old web development consultancy, specializing exclusively in Ruby since Rails 1.0. We now provide an Advanced Rails training class, sharing our lessons from the trenches and interactively taking participants through the source and development process of a real-world app, Umbrella Today.