FIGI is a super simple configuration library you can use in your ruby application.
Add this line to your application's Gemfile:
gem 'figi'
And then execute:
$ bundle
Or install it yourself as:
$ gem install test
- Support JSON and YAML file
require 'figi' Figi::Config.from_json('config/config.json') Figi::Config.from_yaml('config/config.yml') puts figi.environment # => development
- Method access
require 'figi' figi.host = 'localhost' puts figi.host # => localhost puts figi.host? # => true puts figi.not_exists? # => false
- Config once, use everywhere
require 'figi' Figi::Config.load(environment: 'production', username: 'root') puts figi.environment # => production puts figi.username # => root
- Config with DSL
Figi::Config.load do |config| config.environment = 'production' config.username = 'root' end puts figi.environment # => production
- Nested method access
# nested access figi.db = { host: 'localhost', port: 27017 } puts(figi.db.host) # => localhost puts(figi.db.port) # => 27017
Bug reports and pull requests are welcome on GitHub at https://github.com/zt2/figi.
The gem is available as open source under the terms of the MIT License.