RockConfig is a simple convention based library for reading and accessing config files.
Installation
Add this line to your application's Gemfile:
gem "rock_config"
And then execute:
$ bundle
Or install it yourself as:
$ gem install rock_config
Usage
Given the file elastic_search.yml:
development:
host: 127.0.0.1
port: 9200
production:
host: 192.168.1.10
port: 9200
RockConfig allows you to read these settings with an API like this:
elastic_config = RockConfig.for "elastic_search"
elastic_config.host # > 127.0.0.1
RockConfig automatically chooses the current application environment. You can select the environment yourself with:
RockConfig.for "elastic_search", "production"
RockConfig scans predefined directories for config files. By default, it tries to scan directory
config
in the project root. You can add more directories:
RockConfig.configure do |config|
config.scanned_directories << "custom_path"
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request