k_util 0.0.24 → 0.0.25
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.
- checksums.yaml +4 -4
- data/lib/k_util/data_helper.rb +2 -0
- data/lib/k_util/file_helper.rb +7 -0
- 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: dcac547458215aa41518a6d6c5fa4ecfd5ef310219cfc5a09d371a5081e5c542
|
4
|
+
data.tar.gz: 5ab42859a7c3e72ad2a9f9a8309562dfa6a49259ef8ac9815723e3e91ae65f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 483f2ef0d30165c68f5cad6cd0f1acd199a07ac44fedace7ffe5195c581159f020bb5847a6f009c4a732fac51f8d80c550352ebb4c46430e64521f7b99de4ecb
|
7
|
+
data.tar.gz: de0d1b1776acc57acc51f981dce2ac8c1c4b3a0504db0f4a1c18ba7b49fc6344080aed9532d93ac515d9bb141c60f202ec3d5e8638d82fe33c5b185cc1b98903
|
data/lib/k_util/data_helper.rb
CHANGED
@@ -26,6 +26,7 @@ module KUtil
|
|
26
26
|
|
27
27
|
# Convert various data types (Hash, Array, Struct) into a deep nested OpenStruct
|
28
28
|
#
|
29
|
+
# KUtil.data.to_open_struct(data)
|
29
30
|
# or an array of deep nested OpenStruct
|
30
31
|
def to_open_struct(data)
|
31
32
|
return OpenStruct.new(data.transform_values { |v| to_open_struct(v) }) if data.is_a?(Hash)
|
@@ -38,6 +39,7 @@ module KUtil
|
|
38
39
|
|
39
40
|
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
40
41
|
# Convert data to hash and deal with mixed data types such as Struct and OpenStruct
|
42
|
+
# KUtil.data.to_hash(data)
|
41
43
|
def to_hash(data)
|
42
44
|
# This nil check is only for the root object
|
43
45
|
return {} if data.nil?
|
data/lib/k_util/file_helper.rb
CHANGED
@@ -26,5 +26,12 @@ module KUtil
|
|
26
26
|
def home_or_absolute?(path)
|
27
27
|
home?(path) || absolute?(path)
|
28
28
|
end
|
29
|
+
|
30
|
+
def parse_uri(uri)
|
31
|
+
return uri if uri.is_a?(URI)
|
32
|
+
return URI.parse(uri) if uri =~ URI::ABS_URI # https://stackoverflow.com/questions/1805761/how-to-check-if-a-url-is-valid
|
33
|
+
|
34
|
+
URI.join('file:///', uri)
|
35
|
+
end
|
29
36
|
end
|
30
37
|
end
|
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.25
|
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-12-13 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"
|