README.md in qonfig-0.19.0 vs README.md in qonfig-0.19.1
- old
+ new
@@ -1,10 +1,9 @@
# Qonfig · [![Gem Version](https://badge.fury.io/rb/qonfig.svg)](https://badge.fury.io/rb/qonfig) [![Build Status](https://travis-ci.org/0exp/qonfig.svg?branch=master)](https://travis-ci.org/0exp/qonfig) [![Coverage Status](https://coveralls.io/repos/github/0exp/qonfig/badge.svg?branch=master)](https://coveralls.io/github/0exp/qonfig?branch=master)
Config. Defined as a class. Used as an instance. Support for inheritance and composition.
-Lazy instantiation. Thread-safe. Command-style DSL. Validation layer. **DOT-NOTATION**!
-Support for **YAML**, **TOML**, **JSON**, **\_\_END\_\_**, **ENV**.
+Lazy instantiation. Thread-safe. Command-style DSL. Validation layer. **DOT-NOTATION**! And pretty-print :) Support for **YAML**, **TOML**, **JSON**, **\_\_END\_\_**, **ENV**.
Extremely simple to define. Extremely simple to use. That's all? **NOT** :)
## Installation
```ruby
@@ -937,15 +936,21 @@
---
### Setting key existence
-- `#key?(*key_path)` / `#option?(*key_path)` / `#setting?(*key_path)`
+- supports **dynamic array-like format** and **canonical dot-notation format**;
+- returns `true` if the concrete key is exist;
+- returns `false` if the concrete key does not exist;
+- **dynamic array-like format**:
+ - `#key?(*key_path)` / `#option?(*key_path)` / `#setting?(*key_path)`;
- `*key_path` - an array of symbols and strings that represents a path to the concrete setting key;
- (for example, `config.key?(:credentials, :user)` tries to check that `config.settings.credentials.user` is exist);
- - returns `true` if the concrete key is exist;
- - returns `false` if the concrete key does not exist;
+- **dot-notation format**:
+ - `#key?(key)` / `#option?(key)` / `#setting?(key)`;
+ - `key` - string in dot-notated format
+ - (for example: `config.key?('credentials.user')` tries to check that `config.settings.crednetials.user` is exist);
```ruby
class Config < Qonfig::DataSet
setting :credentials do
setting :user, 'D@iVeR'
@@ -953,19 +958,25 @@
end
end
config = Config.new
+# --- array-like format ---
config.key?('credentials', 'user') # => true
config.key?('credentials', 'token') # => false (key does not exist)
+# --- dot-notation format ---
+config.key?('credentials.user') # => true
+config.key?('credentials.token') # => false (key does not exist)
+
config.key?('credentials') # => true
config.key?('que_adapter') # => false (key does not exist)
# aliases
config.setting?('credentials') # => true
config.option?(:credentials, :password) # => true
+config.option?('credentials.password') # => true
```
---
### Run arbitrary code with temporary settings
@@ -1146,11 +1157,11 @@
### Export config settings
- all config objects can export their settings to an arbitrary object as singleton methods;
- (**IMPORTANT**) `export_settings` exports config settings as access methods to config's settings (creates `attr_reader`s for your config);
-- signature: `#export(exportable_object, *setting_keys, mappings: {}, prefix: '', raw: false)`:
+- signature: `#export_settings(exportable_object, *setting_keys, mappings: {}, prefix: '', raw: false)`:
- `exportable_object` - an arbitrary object for exporting;
- `*setting_keys` - an array of dot-notaed config's setting keys that should be exported
(dot-notaed key is a key that describes each part of nested setting key as a string separated by `dot`-symbol);
- last part of dot-notated key will become a name of the setting access instance method;
- `mappings:` - a map of keys that describes custom method names for each exported setting;
@@ -1176,11 +1187,11 @@
service = ServiceObject.new
service.config_account # => NoMethodError
# NOTE: export settings as access methods to config's settings
-config.export(service, 'web_api.credentials.account', prefix: 'config_')
+config.export_settings(service, 'web_api.credentials.account', prefix: 'config_')
service.config_account # => { "login" => "D@iVeR", "auth_token" => "IAdkoa0@()1239uA" }
```
---
@@ -2653,10 +2664,10 @@
Qonfig.enable(:pretty_print) # or Qonfig.enable('pretty_print')
# -- or --
Qonfig.load(:pretty_print) # or Qonfig.load('pretty_print')
```
-- show load plugins:
+- show loaded plugins:
```ruby
Qonfig.loaded_plugins # => ["pretty_print"]
# -- or --
Qonfig.enabled_plugins # => ["pretty_print"]