Config loads layered YAML settings with ERB, per-environment files, and a global Settings object. It targets Rails, Sinatra, Padrino, and other Ruby projects.
Overview
Config manages environment-specific application settings from YAML files. Files can embed ERB, inherit values across environments, and merge in a defined order so later sources override earlier ones. After setup, a Settings object exposes values through dot notation and nested hash access, with reload and runtime source APIs.
Rails installs via a generator that adds an initializer and default settings.yml plus environment splits and local overrides ignored from git. Padrino and Sinatra register the gem and point it at config roots; other Ruby apps initialize it inside configure blocks. Local developer files such as settings.local.yml stay out of version control; tests skip the generic local file to avoid flaky machinespecific values.
Environment variables can override file settings when use_env is enabled, with configurable prefix, separator, and type parsing, including Heroku-style ENV usage. Optional dry-schema or dry-validation contracts validate required keys and types. AWS Secrets Manager JSON can feed an EnvSource for the same parsing rules.
Merge behavior is tunable for arrays, nested hashes, knockout prefixes, and nil overwrites. Developers can append or prepend YAML paths, hashes, or secrets at boot or during tests to simulate production settings.
Key features
- Layered YAML configuration files
- ERB evaluation in YAML
- Global Settings object access
- Per-environment and local overrides
- ENV variable overrides
- Optional dry-schema validation
- Runtime add and prepend sources
Use cases
- Rails app secrets and feature flags
- Sinatra service configuration
- Heroku ENV-driven settings
- Test suites loading production YAML