konfigyu 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -3
- data/lib/konfigyu/config.rb +17 -0
- data/lib/konfigyu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32dc96639ce0f4aba6127b0256ca6561c74d4d48a72091dc33433e57fae77b99
|
4
|
+
data.tar.gz: 1fbcafd6dc4e45a21871d1ff9c80795ff1ba7018dc3b5fc9bf97ef66ba2923fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1f79b6094521e77a363f7b3bc5550d9324bd5ef8180e3cf3949d88e2bd1ddd33b5991a60b79f3983e43a69b2d96ecae77b3290e10b08e126739101ecba245a4
|
7
|
+
data.tar.gz: ad1bfaae15b71a9102a8e7d4d2e2a53eff96b57dfbe79e410cce39d4b597665005a053cec5b4085add47875467ef6cedde5ff04969c947df842afacb0bf9ce8e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -51,11 +51,24 @@ require 'konfigyu'
|
|
51
51
|
config = Konfigyu::Config.new('~/konfigyu.yml')
|
52
52
|
```
|
53
53
|
|
54
|
-
You can access the config values through `data
|
54
|
+
You can access the config values directly, through `data`, or through array `[]` notation:
|
55
55
|
|
56
56
|
```ruby
|
57
|
-
puts config.
|
58
|
-
puts config
|
57
|
+
puts config.foo.baz # Outputs "something-else"
|
58
|
+
puts config.data.foo.baz # Outputs "something-else"
|
59
|
+
puts config['foo.baz'] # Also outputs "something-else"
|
60
|
+
```
|
61
|
+
|
62
|
+
There's a caveat with the dot notation that comes from the way methods are interpreted in ruby. If you have a config tree that is the same name as a reserved word in ruby, eg. `class`, you will have to access it through the array `[]` notation instead of the dot notation.
|
63
|
+
|
64
|
+
```yaml
|
65
|
+
class:
|
66
|
+
name: 'Computer Programming'
|
67
|
+
```
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
puts config.class # Outputs: Konfigyu::Config
|
71
|
+
puts config['class'] # Outputs: "Computer Programming"
|
59
72
|
```
|
60
73
|
|
61
74
|
### Required values
|
data/lib/konfigyu/config.rb
CHANGED
@@ -42,6 +42,23 @@ module Konfigyu
|
|
42
42
|
data.get(key)
|
43
43
|
end
|
44
44
|
|
45
|
+
def respond_to_missing?(method_name, _include_private = false)
|
46
|
+
data && !deep_key_exists?(method_name.to_s.chomp('=')).nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing(method_name, *args, &block)
|
50
|
+
return super unless data
|
51
|
+
|
52
|
+
config_chain = method_name.to_s
|
53
|
+
if !config_chain.chomp!('=').nil?
|
54
|
+
data[config_chain] = args.first
|
55
|
+
elsif deep_key_exists?(config_chain)
|
56
|
+
data[config_chain]
|
57
|
+
else
|
58
|
+
super
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
45
62
|
private
|
46
63
|
|
47
64
|
def validate_usage
|
data/lib/konfigyu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konfigyu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Gourley
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syck
|