Testcloud Config
Testcloud config is a library for managing configuration options in gems, rails apps, and generic ruby projects.
It currently handles loading yaml files based off of an environment. If you are not using environments in your project, it requires you to set a 'default' as your root yaml node.
Usage
Say we have this directory structure:
config/
redis.yml
And redis.yml looks like this:
test:
url: 'redis://localhost:6378'
development:
url: 'redis://password@localhost:6379'
production:
url: 'redis://[email protected]:4000'
Then we can load the file like so:
Testcloud::Config.setup do |config|
config.environment = 'test'
# set the path to your root config directory
config.config_directory = '/path/to/config'
# set the name of the class you want to use
# to access the parsed config hash
config.config_classname = 'Configuration'
# automatically load/parse files after
# this setup block finishes executing
config.eager_load = true
end
And now we can do the following:
Configuration.redis.url #=> 'redis://localhost:6378'
# oops, redis.yml had the wrong port
# we edit redis.yml and then call reload!
Testcloud::Config.reload!
Configuration.redis.url #=> 'redis://localhost:6379'