Configatron 1.0.0 Released!

Configatron makes configuring your applications and scripts incredibly easy. No longer is a there a need to use constants or global variables. Now you can use a simple and painless system to configure your life. And, because it’s all Ruby, you can do any crazy thing you would like to! API

Note: Configatron is a general purpose library, that can be used in ANY Ruby application or script, it’s not Mack specific. So go on and configure to your hearts content. :)

$ sudo gem install configatron

Examples

Simple

Now, anywhere in your code you can do the following:

Viola! Simple as can be.

Now you’re saying, what if I want to have a ‘default’ set of options, but then override them later, based on other information? Simple again. Let’s use our above example. We’ve configured our ‘database_url’ option to be “postgres://localhost/mack_framework_rocks”. The problem with that is that is our production database url, not our development url. Fair enough, all you have to do is redeclare it:

becomes:

Notice how our other configuration parameters haven’t changed? Cool, eh?

Namespaces

The question that should be on your lips is what I need to have namespaced configuration parameters. It’s easy! Configatron allows you to create namespaces.

becomes:

Configatron allows you to nest namespaces to your hearts content! Just keep going, it’s that easy.

Enjoy!

Tags:

16 Responses to “Configatron 1.0.0 Released!”

  1. Sebastian Says:

    So – this looks cool, but my question is: what is the output from your examples? Is this a Mack-specific thing?

    I actually have a great use for this at work if it’s a standalone thing. Could I use Configatron to key off a template, or use it in some kind of templating scenario?

  2. Robin Kaarsgaard Says:

    Very nice initiative! It all looks quite clean and elegant, and the idea of a universal configuration system is really cool! Bravo!

  3. Mark Bates Says:

    It’s completely separate from Mack. As of right now it’s not even being used by Mack, but it will be in a couple of releases. Changing out a configuration system is a big deal in a framework, so I’m waiting for a major release to do it. It’s actually be extracted from another project entirely.

    To use it just require ‘rubygems’ and then require ‘configatron’ and you’ll be all set!

    Enjoy!

  4. Mark Bates Says:

    Also, Sebestian, not sure what you’re templating needs are, but have you checked out Genosaurus? http://genosaurus-api.mackframework.com/ It’s a simple and easy to generator system. Not sure if that helps, but I figured I would throw it out there. :)

  5. George Anderson Says:

    > sudo gem install configatron

    if that’s not obvious.

    And thanks for sharing your code.

  6. Luke Redpath Says:

    Have you looked at SimpleConfig? It already seems to do what configatron does, although it is distributed as a Rails plugin:

    http://github.com/lukeredpath/simpleconfig/tree/master

  7. Mark Bates Says:

    SimpleConfig looks nice, but it definitely has a few differences from Configatron. The first big difference is that SimpleConfig is limited to use with Rails. Configatron can be used with any framework, any application, and any script. Configatron also seems a bit easier to use. There are no mixins needed to use it. The configatron method lives in Kernel, which means it’s available everywhere, no ‘configuration’ needed. :) Different strokes, eh? There are a few other configuration systems out there, I always encourage people to check out the options before they decide on a piece of software to use.

  8. Soleone Says:

    Haha, just today I was thinking of inventing a library that does something like this myself. Great work, love the simplicity!

    Would be cool though if it also worked with yaml files, and if you could configure it to use another word than ‘configatron’.

  9. Mark Bates Says:

    I’ve been meaning to add a configure_from_yaml file method to it, I’ll see if I can get to it this week. There’s a configure_from_hash method you could use in the meantime. If you don’t like the method name configatron, you can easily just alias it off to something else. I used it because I felt pretty confident that no one else would be using that name in their apps. :)

  10. Soleone Says:

    Allright, haven’t thought about aliasing. Thanks for the hint, works great! I will definitely use this in future projects, especially with the yaml support coming ;) Because I want end users of my config file only to see the bare minimum (which means possibly no ruby code block)

  11. Mark Bates Says:

    Soleone, glad you like it, I do too. :) In the meantime, before YAML support comes along, hopefully this week, maybe next, you can use the configure_from_hash method, just pass it YAML.load(‘/path/to/file.yml’), and it should work just fine.

  12. A Fresh Cup » Blog Archive » Double Shot #281 Says:

    [...] Configatron 1.0.0 Released – General-purpose manager for configuration variables in Ruby applications. (via RubyFlow) [...]

  13. Diego Algorta Says:

    Have you seen Mhash?

    It’s not exactly a configuration framework… but looking at configatron reminded me about Mhash. I see similarities. And maybe, I’d like configatron to get rid of the explicit namespace creation. Maybe you’d like to consider using Mhash as the underlying object behind configatron?

  14. Diego Algorta Says:

    Forgot to include the link:
    http://www.intridea.com/2008/4/13/mash-mocking-hash-for-total-poser-objects

  15. Configatron 1.1.0 Released — Mack Framework Says:

    [...] the heels of last week’s successful release of Configatron 1.0.0 comes version 1.1.0. The big addition, feature wise, to 1.1.0 is the ability [...]

  16. Mark Bates Says:

    Thanks Diego, I’ll check it out. It might be a better way of storing stuff under the covers. Thanks.