A simple module to read configuration files, currently has support to:
- yaml
Add this to your application's shard.yml
:
dependencies:
config:
github: whity/crystal-config
require "config/yaml" # for yaml files
require "config/hash" # for hash objects
# instanciate object
config = Config::Hash.new({
"key1": "1234",
"key2": "123344",
"hash": {
"key1": "56",
"key2": "ehehe"
}
})
# for yaml, Config::Yaml.new("filename")
# get key
puts config.get("key1")
puts config["hash.key2"]
# merge with another object
config2 = Config::Hash.new({
"key3": "ohohohooh"
})
config = config.merge(config2) # or config.merge!(config2)
- Fork it ( https://github.com/whity/crystal-config/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- whity(https://github.com/whity) André Brás - creator, maintainer