README.md in basic_config-0.0.2 vs README.md in basic_config-0.1.0

- old
+ new

@@ -1,9 +1,7 @@ -# BasicConfig +# BasicConfig [![Build Status](https://secure.travis-ci.org/stephan778/basic_config.png)](http://travis-ci.org/stephan778/basic_config) -[![Build Status](https://secure.travis-ci.org/stephan778/basic_config.png)](http://travis-ci.org/stephan778/basic_config) - Friendly configuration wrapper. If you find yourself using things like: ```ruby AppConfig = YAML.load_file('config/app.yml')[environment].symbolize_keys ``` @@ -73,13 +71,26 @@ make a typo) - you'll get a `nil`. Worst case: this `nil` will live inside your system compromising or corrupting some data until you finally notice and track it down back to this line. If you are using a `BasicConfig`: ```ruby +AppConfig = BasicConfig.load_env('config/application.yml', 'development') secret_token = AppConfig.something ``` -you'll get `NoMethodError` in that particular line with the name of the key that -is missing. +you'll get `BasicConfig::NotFound` exception with a message similar to this: + + Configuration key 'development.something' is missing in config/application.yml + +if you're constructing BasicConfig with `new`, then it'll show source code +location where BasicConfig is initialized. + +```ruby +AppConfig = BasicConfig.new({ secret_token: 'something' }) +secret_token = AppConfig.secret_toklen # Note a typo here + +# Will result in exception: +# BasicConfig::NotFound: Configuration key 'secret_toklen' is missing in BasicConfig constructed at your_file.rb:5 in `new' +``` *Note:* There is also an `include?` method which you can use to check if particular key exist in your config - `AppConfig.include?(:something)`. Additionaly, for some keys it makes sense to get a `nil` when they do not exist and for this purpose there is a `[]` method which is delegated to underlying hash.