Tuesday 24 May 2011

plugin for loading application constants in rails.

https://github.com/shilesh/app_config


I have created a simple plugin which could be helpful in your rails projects. It is available at https://github.com/shilesh/app_config . This plugin, once installed , loads constants from a config file, while the application gets initialized (server start/restart, rails console etc ...). 

There will be situations when application specific constants are required in our application. Which we could configure as needed.

Summary:
=======
This plugin helps to load values from a config file(yml) file based on the 
environment, with out writing extra code. ie: if you have a config file as 'app_config.yml' and has values in it as title: 'Caption'.The plugin helps you to call as "AppConfig::TITLE". If your config file name is 'ror_values.yml' then the values can be accessed as RorValue::TITLE". In short ::.
 
I have tested against ruby 1.9 and rails 3.0

How to use:
==========
  1. Install the plugin.
  2. This will create a folder 'app_config' inside 'config' folder of your rails application.
  3. A mock config file, named 'app_config.yml', will be created with sample data.
  4. User can edit the file with proper values.
  5. The file name can be renamed
  6. Based on the file name the namescope will be created to access the values( :: ).
  7. Restart the server if you change the file name.
  8. You can expect helpful error messages being raised on invalid access.
  9. When you un-install the files in config/app_config/* will be retained, 
  10. expecting that it would contain useful data. You can manually delete it if needed.
   

    I have tested it against rails 3.0.x and 2.3.8 .

No comments:

Post a Comment