tiny_dot 3.0.0 → 3.1.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 +17 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44f7c9f36e7b3d775cf41774060f0144b5db9006922f271a246aed612288d2bc
4
- data.tar.gz: db865874e1f5b854d6b7b34362e1e5efab6f8340551c5725007f09cd0bc67ca9
3
+ metadata.gz: bfdf22071f9f96708a8ef78bb8a0a0560e177bead5813a8f3a96f5d570bfcb26
4
+ data.tar.gz: 804dd96f4668069a55e3351688de2549eafabb6846164526ab29582e6fabb84c
5
5
  SHA512:
6
- metadata.gz: c5bddb3ad6272bb1b3362f79be814ed6c4bc8585b9d1639595055c44c7d9969da4c099a0228ed389cae4eeab3453ac448cdc5570fee0228e5feefb476f01c624
7
- data.tar.gz: 953bcffe9fc13b98ed22b40fdd7a56bde7f889eb775d90eb3b9480e94167573fa875b07f57be6ea887d0a92010e7563827d0e2068b2dc89f54165c081e2ed909
6
+ metadata.gz: 860053a3e01e0b8b40faf0d17fe1adf121145231463eb640b796a6cad59ccb4a54dc86bc7c02558c2e5f81cc20ac16badd7dfd0372254a2949bb5d336f0ea097
7
+ data.tar.gz: 23019cb6b857e282f9565d1749c8107aed418c239e569115272c634bbdbd5b8fc7e2b8fe23761926affcc98ac6a80c638a13c388ea875c74af7713abcf049bb0
data/lib/tiny_dot.rb CHANGED
@@ -27,6 +27,17 @@ require 'oj'
27
27
  # replaces spaces and dashes with underscores and converts the keys to symbols.
28
28
  #
29
29
  # Please note that the JSON and YAML are required to be passed as String.
30
+ #
31
+ # Because this module constructs a series of nested Structs from Hash-like
32
+ # inputs, it means you can read/write data pretty easily:
33
+ #
34
+ # > s = TinyDot.from_json(<some deeply nested JSON>)
35
+ # => <struct ... >
36
+ # > s.foo.bar.baz
37
+ # => 5
38
+ # > s.foo.bar.baz = 99
39
+ # < s.foo.bar.baz
40
+ # => 99
30
41
  module TinyDot
31
42
  class << self
32
43
  def from_env
@@ -38,11 +49,16 @@ module TinyDot
38
49
  _hash_to_struct(yaml)
39
50
  end
40
51
 
41
- def self.from_json(json_string)
52
+ def from_json(json_string)
42
53
  json = Oj.load(json_string)
43
54
  _hash_to_struct(json)
44
55
  end
45
56
 
57
+ def from_csv(csv_string)
58
+ data = CSV.parse(csv_string, headers: true)
59
+ data.map { |row| _hash_to_struct(row.to_hash) }
60
+ end
61
+
46
62
  def self.from_hash(hash)
47
63
  _hash_to_struct(json)
48
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_dot
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-27 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a tiny read/write dot notation wrapper for Hash, JSON, YAML, and ENV
14
14
  email: jefflunt@gmail.com