k_util 0.0.25 → 0.0.26

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: dcac547458215aa41518a6d6c5fa4ecfd5ef310219cfc5a09d371a5081e5c542
4
- data.tar.gz: 5ab42859a7c3e72ad2a9f9a8309562dfa6a49259ef8ac9815723e3e91ae65f7f
3
+ metadata.gz: fea6ad816bc7b0e7d628f3726b0ba6d3f731e185405c982ff74a082e7dbaacfd
4
+ data.tar.gz: a89a98739a7ef4a2fee5ff1a7ceabeba1ff55e63238382969e99443d235e5b23
5
5
  SHA512:
6
- metadata.gz: 483f2ef0d30165c68f5cad6cd0f1acd199a07ac44fedace7ffe5195c581159f020bb5847a6f009c4a732fac51f8d80c550352ebb4c46430e64521f7b99de4ecb
7
- data.tar.gz: de0d1b1776acc57acc51f981dce2ac8c1c4b3a0504db0f4a1c18ba7b49fc6344080aed9532d93ac515d9bb141c60f202ec3d5e8638d82fe33c5b185cc1b98903
6
+ metadata.gz: d9b54e54f72d4555cc9ea62710780857f3a8c5007e9fc15599ad1ce54e509595e0517c4d6e1cb01e991457222b6d0f715541248c1d92bd31e057a7f1c25225f8
7
+ data.tar.gz: 793c00959b89a70933b72d4266dfddea2b1911d7e06f3e3fba4b4011495240e12bc90d73520aa99d7c40edb8fa4feb6996ae55969fa0e43e607e8a144800c6de
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Provide data object helper functions
4
+ # include KUtil::Data::InstanceVariablesToH
4
5
  module KUtil
5
6
  module Data
6
7
  # Helper methods attached to the namespace for working with Data
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Provide data object helper functions
4
+ # include KUtil::Data::InstanceVariablesToH
5
+ module KUtil
6
+ module Data
7
+ # Helper methods attached to the namespace for working with Data
8
+ module InstanceVariablesToSymbolizedHash
9
+ def to_h
10
+ hash = {}
11
+ instance_variables.each do |var|
12
+ value = instance_variable_get(var)
13
+
14
+ value = KUtil.data.to_hash(value) if KUtil.data.hash_convertible?(value)
15
+
16
+ hash[var.to_s.delete('@').to_sym] = value
17
+ end
18
+ hash
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Provide file helper functions
4
+ module KUtil
5
+ # Helper methods attached to the namespace to run Open3 commands
6
+ class Open3Helper
7
+ def capture2(cmd, **opts)
8
+ output, status = Open3.capture2(cmd, **opts)
9
+
10
+ unless success?
11
+ binding.pry
12
+ end
13
+
14
+ raise Open3Error unless status.success?
15
+
16
+ output
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KUtil
4
- VERSION = '0.0.25'
4
+ VERSION = '0.0.26'
5
5
  end
data/lib/k_util.rb CHANGED
@@ -1,25 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open3'
4
+
3
5
  require 'k_util/version'
4
6
  require 'k_util/console_helper'
5
7
  require 'k_util/data/instance_variables_to_h'
8
+ require 'k_util/data/instance_variables_to_symbolized_hash'
6
9
  require 'k_util/data_helper'
7
10
  require 'k_util/file_helper'
11
+ require 'k_util/open3_helper'
8
12
 
9
13
  # Provide various helper functions
10
14
  module KUtil
11
- # raise KUtil::Error, 'Sample message'
12
- # class Error < StandardError; end
15
+ # raise KUtil::Open3Error, 'Sample message'
16
+ Open3Error = Class.new(StandardError)
13
17
 
14
18
  class << self
15
19
  attr_accessor :console
16
20
  attr_accessor :data
17
21
  attr_accessor :file
22
+ attr_accessor :open3
18
23
  end
19
24
 
20
25
  KUtil.console = KUtil::ConsoleHelper.new
21
26
  KUtil.data = KUtil::DataHelper.new
22
27
  KUtil.file = KUtil::FileHelper.new
28
+ KUtil.open3 = KUtil::Open3Helper.new
23
29
  end
24
30
 
25
31
  if ENV['KLUE_DEBUG']&.to_s&.downcase == 'true'
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.25
4
+ version: 0.0.26
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-12-13 00:00:00.000000000 Z
11
+ date: 2022-01-17 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"
@@ -41,8 +41,10 @@ files:
41
41
  - lib/k_util.rb
42
42
  - lib/k_util/console_helper.rb
43
43
  - lib/k_util/data/instance_variables_to_h.rb
44
+ - lib/k_util/data/instance_variables_to_symbolized_hash.rb
44
45
  - lib/k_util/data_helper.rb
45
46
  - lib/k_util/file_helper.rb
47
+ - lib/k_util/open3_helper.rb
46
48
  - lib/k_util/version.rb
47
49
  homepage: http://appydave.com/gems/k-util
48
50
  licenses:
@@ -66,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
68
  - !ruby/object:Gem::Version
67
69
  version: '0'
68
70
  requirements: []
69
- rubygems_version: 3.2.7
71
+ rubygems_version: 3.2.33
70
72
  signing_key:
71
73
  specification_version: 4
72
74
  summary: KUtil provides simple utility methods