k_util 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88c89c4c9e613a825a162a59b8b4ea546d747f223d4d93ce93f26b3c734d49c2
4
- data.tar.gz: 94b16c31d2149012c947e85a677f36b33f559cd914636269f8b5ce9bb9bc56bb
3
+ metadata.gz: c8615e74388467bff65c418f4367b9a6946ad9f1ed9dc7aaee45ccd81774a437
4
+ data.tar.gz: 8c752c2c0210b4aea25afeb5a6d41847a138d11a2af5e16bcad0d8ea35499b5d
5
5
  SHA512:
6
- metadata.gz: ca99065afbe8883d234c30a4cef1b56c69d2be2fd48860918158f0f1df8bc40cd77cc23b0a72a459ab765a1bb1c7b944f1ef6bc67b1c85a840a6df8c8a13cf24
7
- data.tar.gz: fef92543798f378b9aedb86f1db84619b2a82fb0246f13ac1e99932def8e37a4bd391aa24a5411c3726aaea807b37cb22f33115fc47cc40c0ae404b67d8e4b2b
6
+ metadata.gz: ac0a9551cc6a4c8c463e0bdc8b4b209695d5d8a1fcfd7c633cdc33488725d81f9479f91e54ea3393d66312543135149a9838dce70eeb46943e1b868be564aa31
7
+ data.tar.gz: 6512cfa298e0bf08f3b29776326dd8e8be3ebe8a0c3162c2be8764cf791748d5421ee4efd14606c65b8192351e3163a8249a610abd9481258744dae95e045d33
data/lib/k_util.rb CHANGED
@@ -9,4 +9,14 @@ require 'k_util/file_helper'
9
9
  module KUtil
10
10
  # raise KUtil::Error, 'Sample message'
11
11
  # class Error < StandardError; end
12
+
13
+ class << self
14
+ attr_accessor :console
15
+ attr_accessor :data
16
+ attr_accessor :file
17
+ end
18
+
19
+ KUtil.console = KUtil::ConsoleHelper.new
20
+ KUtil.data = KUtil::DataHelper.new
21
+ KUtil.file = KUtil::FileHelper.new
12
22
  end
@@ -11,14 +11,12 @@ module KUtil
11
11
  # Convert a hash into a deep OpenStruct or array an array
12
12
  # of objects into an array of OpenStruct
13
13
  # Generate hyper link encoded string for the console
14
- def self.file_hyperlink(text, file)
14
+ def file_hyperlink(text, file)
15
15
  "\u001b]8;;file://#{file}\u0007#{text}\u001b]8;;\u0007"
16
16
  end
17
17
 
18
- def self.hyperlink(text, link)
18
+ def hyperlink(text, link)
19
19
  "\u001b]8;;#{link}\u0007#{text}\u001b]8;;\u0007"
20
20
  end
21
21
  end
22
22
  end
23
-
24
- KUtil.console = KUtil::ConsoleHelper
@@ -2,15 +2,11 @@
2
2
 
3
3
  # Provide data object helper functions
4
4
  module KUtil
5
- class << self
6
- attr_accessor :data
7
- end
8
-
9
5
  # Helper methods attached to the namespace for working with Data
10
6
  class DataHelper
11
7
  # Convert various data types (Hash, Array, Struct) into a deep nested OpenStruct
12
8
  # or an array of deep nested OpenStruct
13
- def self.to_open_struct(data)
9
+ def to_open_struct(data)
14
10
  case data
15
11
  when Hash
16
12
  OpenStruct.new(data.transform_values { |v| to_open_struct(v) })
@@ -28,7 +24,7 @@ module KUtil
28
24
  end
29
25
 
30
26
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
31
- def self.to_hash(data)
27
+ def to_hash(data)
32
28
  # No test yet
33
29
  if data.is_a?(Array)
34
30
  return data.map { |v| v.is_a?(OpenStruct) ? to_hash(v) : v }
@@ -49,12 +45,10 @@ module KUtil
49
45
  end
50
46
  # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
51
47
 
52
- def self.clean_symbol(value)
48
+ def clean_symbol(value)
53
49
  return value if value.nil?
54
50
 
55
51
  value.is_a?(Symbol) ? value.to_s : value
56
52
  end
57
53
  end
58
54
  end
59
-
60
- KUtil.data = KUtil::DataHelper
@@ -2,13 +2,9 @@
2
2
 
3
3
  # Provide file helper functions
4
4
  module KUtil
5
- class << self
6
- attr_accessor :file
7
- end
8
-
9
5
  # Helper methods attached to the namespace for working with Files
10
6
  class FileHelper
11
- def self.expand_path(filename, base_path = nil)
7
+ def expand_path(filename, base_path = nil)
12
8
  if pathname_absolute?(filename)
13
9
  filename
14
10
  elsif filename.start_with?('~/')
@@ -18,10 +14,8 @@ module KUtil
18
14
  end
19
15
  end
20
16
 
21
- def self.pathname_absolute?(pathname)
17
+ def pathname_absolute?(pathname)
22
18
  Pathname.new(pathname).absolute?
23
19
  end
24
20
  end
25
21
  end
26
-
27
- KUtil.file = KUtil::FileHelper
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KUtil
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys