mysticonfig
🔮 The configuration loader for wizard.
A library to load .appnamerc
, .appnamerc.json
or .appnamerc.yaml
config file easily.
mysticonfig
will lookup for your config file.
It keeps traversing up until it finds the config file or reaches your home directory.
Gem's name inspired by cosmiconfig
Installation
gem install mysticonfig
Usage
Normal
require 'mysticonfig'
loader = Mysticonfig::Loader.new 'appname'
config = loader.load # Automatically detect and load config
json_config = loader.load_json # Only load config from JSON file
yaml_config = loader.load_yaml # Only load config from YAML file (.yaml or .yml)
With default config fallback
require 'mysticonfig'
DEFAULT_CONFIG = {
'a' => 'A',
'b' => 'B',
'c' => 'C'
}
loader = Mysticonfig::Loader.new('appname', DEFAULT_CONFIG)
config = loader.load # Automatically detect and load config
json_config = loader.load_json # Only load config from JSON file
yaml_config = loader.load_yaml # Only load config from YAML file (.yaml or .yml)