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 +4 -4
- data/lib/k_util/data_helper.rb +9 -1
- data/lib/k_util/version.rb +1 -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: 1cc4532082b846b6644fab95de5f16943585311d07b7dab25247418e62960e93
|
4
|
+
data.tar.gz: 59025e0e712857e698aa30242be084d0a85ab3020cea20a6f7fd49c153a2537e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e2cdc37229d364f87dcb196a6366d1cf86e62e30634b1fff4fcc6ee5dac941396a145a052337c2b1d56a85180640c69b84c18f80c932ec667047163106cc3a
|
7
|
+
data.tar.gz: e839e60ad5abb4b00e0e46f66172255fb20976e4de99b44d80fc7d64d53fa798b5c73d82de9d6d6c9228173c19d43408c2ac81dfda91d6f471d597c67c9d30b6
|
data/lib/k_util/data_helper.rb
CHANGED
@@ -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
|
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) ||
|
data/lib/k_util/version.rb
CHANGED
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.
|
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-
|
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"
|