k_util 0.0.24 → 0.0.25

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: 8b52770ba6a289d791e99eb4fcf868f87281200424ff7817c07e10b8dd1a4701
4
- data.tar.gz: 23ec84b2db507096fd6593360c08570fcb3eac84676edd89f94666b81d8c1a28
3
+ metadata.gz: dcac547458215aa41518a6d6c5fa4ecfd5ef310219cfc5a09d371a5081e5c542
4
+ data.tar.gz: 5ab42859a7c3e72ad2a9f9a8309562dfa6a49259ef8ac9815723e3e91ae65f7f
5
5
  SHA512:
6
- metadata.gz: 78ee597e330cda00891023bb95bbbacfe07178accad429d4724805a7f60f853d0ace04c74ff91c540b3a71a34ef722e3cd1606092c957ac5a368aa7c440a38cd
7
- data.tar.gz: 0f7f5913e389eb066f42819040211d68791735a32b9c1af3572fdd08712adcbe4ddfb5c1e3732004be89ef4ba842ef5a339887021426e1e655b6d06ed64135f6
6
+ metadata.gz: 483f2ef0d30165c68f5cad6cd0f1acd199a07ac44fedace7ffe5195c581159f020bb5847a6f009c4a732fac51f8d80c550352ebb4c46430e64521f7b99de4ecb
7
+ data.tar.gz: de0d1b1776acc57acc51f981dce2ac8c1c4b3a0504db0f4a1c18ba7b49fc6344080aed9532d93ac515d9bb141c60f202ec3d5e8638d82fe33c5b185cc1b98903
@@ -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?
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KUtil
4
- VERSION = '0.0.24'
4
+ VERSION = '0.0.25'
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.24
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-08-28 00:00:00.000000000 Z
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"