Project

konf

0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
minimalistic configuration reader
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.6.4
 Project Readme

Konf

Konf is a simple configuration reader.

Setup

Simply install the gem and/or plug this into the Gemfile:

gem 'konf'

Usage

Assuming you have a configuration file like this:

development:
  admin:
    name: Dev
    email: dev@test.test
production:
  admin:
    name: Pro
    email: pro@test.test

You can load a YAML file, or provide a simple Hash and read configuration values like this:

>> conf = Konf.new('configuration.yml')
>> conf.development.name
=> 'Dev'

If you try to read a configuration that wasn't defined:

>> conf.development.invalid
=> Konf::NotFound: No configuration found for 'invalid'

You can check if configuration exists:

>> conf.development.admin?
=> true
>> conf.development.invalid?
=> false

You can namespace your configuration:

>> conf = Konf.new('configuration.yml', 'production')
>> conf.admin.name
=> 'Pro'

Author

(c) 2011 Oleg Khabarov, released under the MIT license