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 +4 -4
- data/lib/k_util/data_helper.rb +17 -0
- data/lib/k_util/version.rb +5 -5
- 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: b57165e4a0192dcffbfd3655e45b326bcc00db6ce32d1b72116516d32d8a5c07
|
4
|
+
data.tar.gz: 79ee2191737f976495009f303fb7db18f0ae9e52b6b344eb642dab5ae2884b6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21de731f6f1d53e8d1a28df7e1f5d80058955a517d774960f0d7362c778062cac0e9445c5d6d2cde6a88a9ce1619810dce9d5103b8a5b62d83707fce34aaabc3
|
7
|
+
data.tar.gz: 6d062276df66896e21ffa92e07dd25d38f7951da46fcaba6ab5ced669cedd7decd669df11a7902b251589e2f17dda4bb2d7aaf61911f5c08277e20a208b6a314
|
data/lib/k_util/data_helper.rb
CHANGED
@@ -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
|
data/lib/k_util/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module KUtil
|
4
|
-
VERSION = '0.0.
|
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.
|
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-
|
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"
|