No commit activity in last 3 years
No release in over 3 years
If you need to create a custom config file for you project, ConfigLoader will help you to load the contents of this file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9
 Project Readme

configloader¶ ↑

If you need to create a custom config file for you Rails project, ConfigLoader will help you to load the contents of this file.

How to install the gem¶ ↑

gem install configloader

Usage¶ ↑

ConfigLoader.load(file_name, running_env, project_root)

Let's assume that you have the special file config/database.yml in your Rails project.
In this example, you are using CouchDB as your database. This file has the content below:

    development:
      server: localhost
      port: 5984
      database_name: addressbook_development

    test:
      server: localhost
      port: 5984
      database_name: addressbook_test

    production:
      server: production.server.com
      port: 5984
      database_name: addressbook_production

In order to access the database configuration for your current environment, you'd write, for instance:

    db_config = ConfigLoader.load('database')
    db_config['server']                     # localhost
    db_config['port']                       # 5984
    db_config['database_name']              # addressbook_development

We're assuming that your current environment is development.

You can get the configuration of a specific running environment writing this:

    db_config = ConfigLoader.load('database', 'production')
    db_config['server']                     # production.server.com
    db_config['port']                       # 5984
    db_config['database_name']              # addressbook_production

You can specify the project root too. If you don't, it will assume the project root is Rails.root.
To change it, write:

    db_config = ConfigLoader.load('database', 'production')
    db_config = ConfigLoader.load('database', 'test', '/home/user/my_special_project_root')

Dinamic keys are also accepted. They're parsed using ERB. So, you're free to write a config file like this:

  test:
    server: <%= `hostname` %>
    port: 5984
    database_name: addressbook_test

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add specs for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Vinicius Teles. See LICENSE for details.