k_util 0.0.26 → 0.0.27

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: fea6ad816bc7b0e7d628f3726b0ba6d3f731e185405c982ff74a082e7dbaacfd
4
- data.tar.gz: a89a98739a7ef4a2fee5ff1a7ceabeba1ff55e63238382969e99443d235e5b23
3
+ metadata.gz: c613a872941e5e87f4e7de5f4d8572ab1347da1e107c34b26438c7691e1aca43
4
+ data.tar.gz: f1c0a56ffb60871e82b0fe4dbe9d7ae7c1d370c6f9b7e8b0dcc463d70bf4eec2
5
5
  SHA512:
6
- metadata.gz: d9b54e54f72d4555cc9ea62710780857f3a8c5007e9fc15599ad1ce54e509595e0517c4d6e1cb01e991457222b6d0f715541248c1d92bd31e057a7f1c25225f8
7
- data.tar.gz: 793c00959b89a70933b72d4266dfddea2b1911d7e06f3e3fba4b4011495240e12bc90d73520aa99d7c40edb8fa4feb6996ae55969fa0e43e607e8a144800c6de
6
+ metadata.gz: 01d75ddf3b0b7d500d3fbd3e0c3f9c6ee7421b058560cdfaff2144e2f07ab43f9f9e01dc92f68aff6001a555b6fd70f3166b26230452c5d1856faaef52fd8b98
7
+ data.tar.gz: abeb63578932c2e8330c672c3ddd62b5d2ca0661d2e038d9b9f20ec49fbea478b49b2d592750adcc7e4b882fa19d2b377fb2d7ec320b749e6860ac9bd313a1b2
@@ -6,14 +6,18 @@ module KUtil
6
6
  module Data
7
7
  # Helper methods attached to the namespace for working with Data
8
8
  module InstanceVariablesToH
9
- def to_h
9
+ def to_h(symbolize_keys: false)
10
10
  hash = {}
11
11
  instance_variables.each do |var|
12
12
  value = instance_variable_get(var)
13
13
 
14
+ # TODO: Add deep support for symbolize_keys
14
15
  value = KUtil.data.to_hash(value) if KUtil.data.hash_convertible?(value)
15
16
 
16
- hash[var.to_s.delete('@')] = value
17
+ key = var.to_s.delete('@')
18
+ key = key.to_sym if symbolize_keys
19
+
20
+ hash[key] = value
17
21
  end
18
22
  hash
19
23
  end
@@ -7,8 +7,9 @@ module KUtil
7
7
  def capture2(cmd, **opts)
8
8
  output, status = Open3.capture2(cmd, **opts)
9
9
 
10
- unless success?
11
- binding.pry
10
+ unless status.success?
11
+ puts "failed to run command: #{cmd}"
12
+ # bxxxinding.pry
12
13
  end
13
14
 
14
15
  raise Open3Error unless status.success?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KUtil
4
- VERSION = '0.0.26'
4
+ VERSION = '0.0.27'
5
5
  end
data/lib/k_util.rb CHANGED
@@ -5,7 +5,6 @@ require 'open3'
5
5
  require 'k_util/version'
6
6
  require 'k_util/console_helper'
7
7
  require 'k_util/data/instance_variables_to_h'
8
- require 'k_util/data/instance_variables_to_symbolized_hash'
9
8
  require 'k_util/data_helper'
10
9
  require 'k_util/file_helper'
11
10
  require 'k_util/open3_helper'
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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-17 00:00:00.000000000 Z
11
+ date: 2022-02-04 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,7 +41,6 @@ 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
45
44
  - lib/k_util/data_helper.rb
46
45
  - lib/k_util/file_helper.rb
47
46
  - lib/k_util/open3_helper.rb
@@ -1,22 +0,0 @@
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