konfigyu 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4325b1cc0a2ef8ef7bb54e8275616ab4f54d859d4ec93e8c9432a5aa7016f3f
4
- data.tar.gz: f91b299f09c3145f457cd70002e5219bb573cab51fb48da25f24ea2ac4172c1d
3
+ metadata.gz: 32dc96639ce0f4aba6127b0256ca6561c74d4d48a72091dc33433e57fae77b99
4
+ data.tar.gz: 1fbcafd6dc4e45a21871d1ff9c80795ff1ba7018dc3b5fc9bf97ef66ba2923fb
5
5
  SHA512:
6
- metadata.gz: 427f916d357a4189dee69e45745bdd94590c62072da88a3d68df0a605927032b498eb5d298e263b0e29bc33f1195c71e70a430f7943e3859c6aa330a169e15b7
7
- data.tar.gz: a581cdd82b0a0d984d4b3c6f969593ecb5bc99ddb190f41eaf92239b3cf72775c10e3f0ec34ae09eb76e81058764329dd0467db554c9698b18166126a7cd1663
6
+ metadata.gz: a1f79b6094521e77a363f7b3bc5550d9324bd5ef8180e3cf3949d88e2bd1ddd33b5991a60b79f3983e43a69b2d96ecae77b3290e10b08e126739101ecba245a4
7
+ data.tar.gz: ad1bfaae15b71a9102a8e7d4d2e2a53eff96b57dfbe79e410cce39d4b597665005a053cec5b4085add47875467ef6cedde5ff04969c947df842afacb0bf9ce8e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- konfigyu (0.1.0)
4
+ konfigyu (0.2.0)
5
5
  syck (~> 1.3.0)
6
6
  sycl (~> 1.6)
7
7
 
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` or through array `[]` notation:
54
+ You can access the config values directly, through `data`, or through array `[]` notation:
55
55
 
56
56
  ```ruby
57
- puts config.data.foo.baz # Outputs "something-else"
58
- puts config['data.foo.baz'] # Also outputs "something-else"
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
@@ -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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Version number
4
4
  module Konfigyu
5
- VERSION = '0.1.0'.freeze
5
+ VERSION = '0.2.0'.freeze
6
6
  end
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.1.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-09-27 00:00:00.000000000 Z
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: syck