k_util 0.0.22 → 0.0.23

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: 615b0deb70283841ac540e1af6a4153dcf7fdb6b1eb85f4710119edd7c662507
4
- data.tar.gz: 0cf049101ab9e7ea4e76943c2e19e69a550d4dca78f31b2a70e6e51f6ca13a5c
3
+ metadata.gz: 1cc4532082b846b6644fab95de5f16943585311d07b7dab25247418e62960e93
4
+ data.tar.gz: 59025e0e712857e698aa30242be084d0a85ab3020cea20a6f7fd49c153a2537e
5
5
  SHA512:
6
- metadata.gz: 5d85601784381afbea1385b067cd646ddb72675a463638b2b4b611fff3657d1924ca4dba2f0ede9fa1bd17090481c54814a31d24f92190a47dfa735512677615
7
- data.tar.gz: 0a15d56a6099b870971367b360fe6a2780c30fcedc1b9b759c6e2cccfe698a4386d2f85af143057c3f4f7df7f3b918ca4b73ba46241f2b6503eeb58756b3e0d8
6
+ metadata.gz: 90e2cdc37229d364f87dcb196a6366d1cf86e62e30634b1fff4fcc6ee5dac941396a145a052337c2b1d56a85180640c69b84c18f80c932ec667047163106cc3a
7
+ data.tar.gz: e839e60ad5abb4b00e0e46f66172255fb20976e4de99b44d80fc7d64d53fa798b5c73d82de9d6d6c9228173c19d43408c2ac81dfda91d6f471d597c67c9d30b6
@@ -8,7 +8,9 @@ module KUtil
8
8
  #
9
9
  # https://docs.ruby-lang.org/en/master/JSON.html
10
10
  # rubocop:disable Naming/MethodParameterName
11
- def json_parse(json, as: :hash)
11
+ def parse_json(json, as: :hash)
12
+ log.block(%i[hash hash_symbolized open_struct], title: 'Help as: ?') if as == :help
13
+
12
14
  case as
13
15
  when :hash
14
16
  JSON.parse(json)
@@ -18,6 +20,7 @@ module KUtil
18
20
  JSON.parse(json, object_class: OpenStruct)
19
21
  end
20
22
  end
23
+ alias json_parse parse_json
21
24
  # rubocop:enable Naming/MethodParameterName
22
25
 
23
26
  # Convert various data types (Hash, Array, Struct) into a deep nested OpenStruct
@@ -54,6 +57,11 @@ module KUtil
54
57
  value.is_a?(Symbol) ? value.to_s : value
55
58
  end
56
59
 
60
+ def symbolize_names(hash)
61
+ hash.transform_keys(&:to_sym)
62
+ end
63
+ alias symbolize_keys symbolize_names
64
+
57
65
  # Is the value a basic (aka primitive) type
58
66
  def basic_type?(value)
59
67
  value.is_a?(String) ||
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KUtil
4
- VERSION = '0.0.22'
4
+ VERSION = '0.0.23'
5
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.22
4
+ version: 0.0.23
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-07-16 00:00:00.000000000 Z
11
+ date: 2021-08-27 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"