MywayConfig¶
Configuration management for Ruby applications with XDG support and auto-configuration from YAML.
MywayConfig extends anyway_config with:
- XDG config file loading - Respects
~/.config/<app>/config.yml - Bundled defaults - Ship defaults with your gem
- Auto-configuration - Define structure once in YAML, access everywhere
- Hash-like behavior -
Enumerablesupport for config sections
Features¶
# Define once in YAML
defaults:
database:
host: localhost
port: 5432
log_level: :info
production:
database:
host: prod-db.example.com
# Access with clean Ruby syntax
config.database.host # => "localhost"
config.database[:host] # => "localhost"
config.database['host'] # => "localhost"
config.log_level # => :info
Quick Example¶
require "myway_config"
module MyApp
class Config < MywayConfig::Base
config_name :myapp
env_prefix :myapp
defaults_path File.expand_path("config/defaults.yml", __dir__)
auto_configure!
end
def self.config
@config ||= Config.new
end
end
# Use it
MyApp.config.database.host
MyApp.config.production?
Installation¶
Or add to your Gemfile:
Configuration Priority¶
Values are loaded in priority order (lowest to highest):
- Bundled defaults (
defaults.yml- thedefaults:section) - Environment overrides (
defaults.yml- e.g.,production:section) - XDG user config (
~/.config/<app>/config.yml) - Project config (
./config/<app>.yml) - Environment variables (
MYAPP_DATABASE__HOST=...) - Constructor overrides
Next Steps¶
- Installation - Get up and running
- Quick Start - Build your first config
- Guides - Deep dive into features
- API Reference - Complete API documentation