k_util 0.0.15 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b521dc46323b33d082574de08feba5ef83f167b0feea433d902217e62c934557
4
- data.tar.gz: 6f4f9aca566de81776cdbe6496772034a13f14a973297f738a9a6ecf6856f3eb
3
+ metadata.gz: b57165e4a0192dcffbfd3655e45b326bcc00db6ce32d1b72116516d32d8a5c07
4
+ data.tar.gz: 79ee2191737f976495009f303fb7db18f0ae9e52b6b344eb642dab5ae2884b6c
5
5
  SHA512:
6
- metadata.gz: cf2a72c8bcb86ca6ac4d1e3b286150bf175c5e95018eef603d32fecd010b490e3f266944642cbe6ad9f66dbedcccf30d8c7b4824ff6feb661ad35f257969965e
7
- data.tar.gz: da68fc44fe300cb6130a4e25a31a57431f47d01152683b76f35d5b16a04d34e121d9d66bcc8971d5e1f70e6fd99d588c20b19f815dc1aa9130b951189a88c8a7
6
+ metadata.gz: 21de731f6f1d53e8d1a28df7e1f5d80058955a517d774960f0d7362c778062cac0e9445c5d6d2cde6a88a9ce1619810dce9d5103b8a5b62d83707fce34aaabc3
7
+ data.tar.gz: 6d062276df66896e21ffa92e07dd25d38f7951da46fcaba6ab5ced669cedd7decd669df11a7902b251589e2f17dda4bb2d7aaf61911f5c08277e20a208b6a314
@@ -4,7 +4,24 @@
4
4
  module KUtil
5
5
  # Helper methods attached to the namespace for working with Data
6
6
  class DataHelper
7
+ # Convert JSON string into to_open_struct but designed to work with a JSON string
8
+ #
9
+ # https://docs.ruby-lang.org/en/master/JSON.html
10
+ # rubocop:disable Naming/MethodParameterName
11
+ def json_parse(json, as: :hash)
12
+ case as
13
+ when :hash
14
+ JSON.parse(json)
15
+ when :hash_symbolized
16
+ JSON.parse(json, symbolize_names: true)
17
+ when :open_struct
18
+ JSON.parse(json, object_class: OpenStruct)
19
+ end
20
+ end
21
+ # rubocop:enable Naming/MethodParameterName
22
+
7
23
  # Convert various data types (Hash, Array, Struct) into a deep nested OpenStruct
24
+ #
8
25
  # or an array of deep nested OpenStruct
9
26
  def to_open_struct(data)
10
27
  case data
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module KUtil
4
- VERSION = '0.0.15'
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module KUtil
4
+ VERSION = '0.0.17'
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-07-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " KUtil provides simple utility methods, such as file helpers, data
14
14
  object helpers and more.\n"