tiny_dot 1.3.0 → 2.0.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 +4 -4
- data/lib/tiny_dot.rb +9 -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: cf92a8ea45b7ed4335f67ffab70f92ca2efd160d9a8da66cdc43d564eabb96b0
|
4
|
+
data.tar.gz: 0a8b2e174a87b622a325a778d9bb72b3bcc5d135727b276beca108903f729edb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1da307f393de8ffe0177cde26cbe84ad10e71d1283e1f7a4dff1de06c4884b3676cdd0240419f1c44c0c0372d0049824c2a1ce4a46bcda2dd1a234cfea7dd0
|
7
|
+
data.tar.gz: 60131e3677e280eeb03bce59fbefcaca4e188b0330c9ed600e5b9b55019c828b1d0e2f38a1f51f5e4fd97f4d853ed9671223110f5ec818efb1d02846f28a66d7
|
data/lib/tiny_dot.rb
CHANGED
@@ -42,18 +42,26 @@ class TinyDot
|
|
42
42
|
TinyDot.new(JSON.parse(IO.read(filename)))
|
43
43
|
end
|
44
44
|
|
45
|
+
# returns a TinyDot instance after parsing the JSON in the string
|
46
|
+
def self.from_json_string(s)
|
47
|
+
TinyDot.new(JSON.parse(s))
|
48
|
+
end
|
49
|
+
|
45
50
|
# give it a Hash and it'll give you dot notation over it
|
46
51
|
def initialize(hash)
|
47
52
|
@data = hash
|
48
53
|
end
|
49
54
|
|
50
|
-
def method_missing(m)
|
55
|
+
def method_missing(m, *args)
|
56
|
+
val = args.first
|
51
57
|
ms = m.to_s
|
52
58
|
|
53
59
|
case @data
|
54
60
|
when Hash
|
55
61
|
if ms.end_with?('!')
|
56
62
|
@data[ms[0..-2]]
|
63
|
+
elsif ms.end_with?('=')
|
64
|
+
@data[m[0..-2]] = val
|
57
65
|
else
|
58
66
|
if @data.has_key?(ms)
|
59
67
|
TinyDot.new(@data[ms])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_dot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Lunt
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: a tiny read
|
13
|
+
description: a tiny read/write dot notation wrapper for Hash, JSON, YAML, and ENV
|
14
14
|
email: jefflunt@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|