Copyright © 2009 Rahmal Conda
The complete solution for Ruby Configuration Management. RConfig is a Ruby library that manages configuration within Ruby applications. It bridges the gap between yaml, xml, and key/value based properties files, by providing a centralized solution to handle application configuration from one location. It provides the simplicity of hash-based access, that Rubyists have come to know and love, supporting your configuration style of choice, while providing many new features, and an elegant API.
Simple, easy to install and use.
Supports yaml, xml, and properties files.
Yaml and xml files supprt infinite level of configuration grouping.
Intuitive dot-notation ‘key chaining’ argument access.
Simple well-known hash/array based argument access.
Implements multilevel caching to reduce disk access.
Short-hand access to ‘global’ application configuration, and shell environment.
Overlays multiple configuration files to support environment, host, and even locale-specific configuration.
The overlay order of the config files is defined by SUFFIXES: * nil * _local * _config * _local_config * _{environment} (.i.e _development) * _{environment}_local (.i.e _development_local) * _{hostname} (.i.e _whiskey) * _{hostname}_config_local (.i.e _whiskey_config_local)
Example:
shell/console => export LANG=en demo.yml => server: address: host.domain.com port: 81 ... application.properties => debug_level = verbose ...
demo.rb =>
require 'rconfig' RConfig.load_paths = ['$HOME/config', '#{APP_ROOT}/config', '/demo/conf'] RConfig.demo[:server][:port] => 81 RConfig.demo.server.address => 'host.domain.com' RConfig[:debug_level] => 'verbose' RConfig[:lang] => 'en' ...