lib/config_loader.rb in configloader-0.2.2 vs lib/config_loader.rb in configloader-0.3.0
- old
+ new
@@ -1,10 +1,9 @@
dependencies = %w(missing_config_file_name_error missing_config_file_error map)
dependencies.each { |dependency| require "config_loader/#{dependency}" }
module ConfigLoader
-
# 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
@@ -34,15 +33,21 @@
# db_config = ConfigLoader.load('database', 'production')
# db_config['server'] # production.server.com
# db_config['port'] # 5984
# db_config['database_name'] # addressbook_production
#
- # Finally, you can specify the project root too. If you don't, it will assume the project root is Rails.root. To change it, write:
+ # 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
def self.load(file_name, running_env = Rails.env, project_root = Rails.root.to_s)
ConfigLoader::Map.new(file_name, running_env, project_root).load
end
-
end