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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_dot.rb +9 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43431e5a7057bc2f6cf613a04764ebffc73888e179a410e584175a82deec7c95
4
- data.tar.gz: 2cd49f38c092aaf60dcd54fc6050aa74daa20d018e0b67d5b7ac29feaf0f7130
3
+ metadata.gz: cf92a8ea45b7ed4335f67ffab70f92ca2efd160d9a8da66cdc43d564eabb96b0
4
+ data.tar.gz: 0a8b2e174a87b622a325a778d9bb72b3bcc5d135727b276beca108903f729edb
5
5
  SHA512:
6
- metadata.gz: 4fc483e2b724ae9280106ac16eb95579638f1209a41f2d5a7f8a65c0113355376c35040fc498ac4e8ee9b4837e6e4823640ae4170f45b181c92243d1a2d60ffd
7
- data.tar.gz: ffa636fb014db58d0cac5095af7a1f0737489482524c12facd792540f320984d26e79eb713cffdda89bd9530397b26889757281e4caedc935914f6d753ef8786
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: 1.3.0
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-only, dot notation wrapper for Hash, JSON, YAML, and ENV
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: []