Sha256: b4387b7f958b46724b5d8ea420dfbe1631eb08c26f68ad7f61b90bfe48169d7e

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

# Strada
Configuration library for ruby with YAML/JSON/TOML backends with unified object
access

## Install
```
 % gem install Strada
```

## Use
### Simple
```
require 'Strada'
cfg  = Strada.cfg
port = cfg.server.port
user = cfg.auth.user
pw   = cfg.auth.password
```
It tried to detect your software name via caller_locations if no ':name'
argument was given.
It automatically loads /etc/name/config and ~/.config/name/config and merges
them together.

### Advanced
```
require 'Strada'
Strada = Strada.new name:    'mykewlapp',
                    default: {'poop'=>'xyzzy'},
                    adapter: 'yaml',
                    usrdir:  '/home/app/config/',
                    sysdir:  '/System/config/',
                    load:    false
Strada.default.poop2 = [1, 2, 3, 4]
Strada.default.starship.poopers = 42
Strada.load :user
if Strada.user.empty?
  Strada.user = Strada.default
  Strada.save :user
end
Strada.load    # load+merges cfg, takes argument :default, :system, :user
Strada.cfg     # merged default + system + user  (merged on load)
Strada.default # default only
Strada.system  # system only
Strada.user    # user only
```

## Reserved methods

* each           - iterate all config keys in current level
* has_key?(arg)  - check if current level has key arg
* [arg]          - fetch arg (useful for non-literal retrieval, instead of using #send)
* key?           - all keys have question mark version reserved, checks if key exists+true (true), exists+false (false), not-exists (nil)
+ all object class methods

## TODO

  * should I add feature to raise on unconfigured/unset?
  * should I always merge to 'cfg' when default/system/config is set?
  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strada-0.0.3 README.md
strada-0.0.2 README.md
strada-0.0.1 README.md