k_util 0.0.25 → 0.0.28
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/.rubocop.yml +5 -1
- data/Gemfile +1 -1
- data/hooks/update-version +1 -1
- data/k_util.gemspec +1 -0
- data/lib/k_util/data/instance_variables_to_h.rb +7 -2
- data/lib/k_util/open3_helper.rb +20 -0
- data/lib/k_util/version.rb +1 -1
- data/lib/k_util.rb +8 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56357183b8ad499df1c975d89323ccadb36320ca5bd0dd8fa32b45189cd50ed8
|
4
|
+
data.tar.gz: 8febfec303b8f12ab406b141141e05df8f5110db0425cccf2b27d429a0b1f26a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5758d9688a7349352fc3e69255ab50d436dc223c36e061e46fa4a36e6b083fe25ef3f7e6c4ffcbb64ca23f3c84c0dfa73b7e586b24a87c01746388ccfd94a9a
|
7
|
+
data.tar.gz: bc915741dbda3cf1d88b9db325aa5d9d70874d61e46e0e042cd5663550a2a08c46deaca5672d9afecc6fca66db7773333ea1732d9dbae4cddc1e2f7bd753bd6c
|
data/.rubocop.yml
CHANGED
@@ -38,7 +38,7 @@ Metrics/MethodLength:
|
|
38
38
|
Layout/LineLength:
|
39
39
|
Max: 200
|
40
40
|
# Ignores annotate output
|
41
|
-
|
41
|
+
AllowedPatterns: ['\A# \*\*']
|
42
42
|
IgnoreCopDirectives: true
|
43
43
|
|
44
44
|
Lint/UnusedMethodArgument:
|
@@ -80,3 +80,7 @@ Style/AccessorGrouping:
|
|
80
80
|
Layout/SpaceBeforeComma:
|
81
81
|
Enabled: false
|
82
82
|
# My Preferences - End
|
83
|
+
|
84
|
+
Style/OpenStructUse:
|
85
|
+
Exclude:
|
86
|
+
- "**/*"
|
data/Gemfile
CHANGED
data/hooks/update-version
CHANGED
data/k_util.gemspec
CHANGED
@@ -1,18 +1,23 @@
|
|
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
|
7
8
|
module InstanceVariablesToH
|
8
|
-
def to_h
|
9
|
+
def to_h(symbolize_keys: false)
|
9
10
|
hash = {}
|
10
11
|
instance_variables.each do |var|
|
11
12
|
value = instance_variable_get(var)
|
12
13
|
|
14
|
+
# TODO: Add deep support for symbolize_keys
|
13
15
|
value = KUtil.data.to_hash(value) if KUtil.data.hash_convertible?(value)
|
14
16
|
|
15
|
-
|
17
|
+
key = var.to_s.delete('@')
|
18
|
+
key = key.to_sym if symbolize_keys
|
19
|
+
|
20
|
+
hash[key] = value
|
16
21
|
end
|
17
22
|
hash
|
18
23
|
end
|
@@ -0,0 +1,20 @@
|
|
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 status.success?
|
11
|
+
puts "failed to run command: #{cmd}"
|
12
|
+
# bxxxinding.pry
|
13
|
+
end
|
14
|
+
|
15
|
+
raise Open3Error unless status.success?
|
16
|
+
|
17
|
+
output
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/k_util/version.rb
CHANGED
data/lib/k_util.rb
CHANGED
@@ -1,28 +1,33 @@
|
|
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'
|
6
8
|
require 'k_util/data_helper'
|
7
9
|
require 'k_util/file_helper'
|
10
|
+
require 'k_util/open3_helper'
|
8
11
|
|
9
12
|
# Provide various helper functions
|
10
13
|
module KUtil
|
11
|
-
# raise KUtil::
|
12
|
-
|
14
|
+
# raise KUtil::Open3Error, 'Sample message'
|
15
|
+
Open3Error = Class.new(StandardError)
|
13
16
|
|
14
17
|
class << self
|
15
18
|
attr_accessor :console
|
16
19
|
attr_accessor :data
|
17
20
|
attr_accessor :file
|
21
|
+
attr_accessor :open3
|
18
22
|
end
|
19
23
|
|
20
24
|
KUtil.console = KUtil::ConsoleHelper.new
|
21
25
|
KUtil.data = KUtil::DataHelper.new
|
22
26
|
KUtil.file = KUtil::FileHelper.new
|
27
|
+
KUtil.open3 = KUtil::Open3Helper.new
|
23
28
|
end
|
24
29
|
|
25
|
-
if ENV
|
30
|
+
if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
|
26
31
|
namespace = 'KUtil::Version'
|
27
32
|
file_path = $LOADED_FEATURES.find { |f| f.include?('k_util/version') }
|
28
33
|
version = KUtil::VERSION.ljust(9)
|
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.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-29 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"
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/k_util/data/instance_variables_to_h.rb
|
44
44
|
- lib/k_util/data_helper.rb
|
45
45
|
- lib/k_util/file_helper.rb
|
46
|
+
- lib/k_util/open3_helper.rb
|
46
47
|
- lib/k_util/version.rb
|
47
48
|
homepage: http://appydave.com/gems/k-util
|
48
49
|
licenses:
|
@@ -51,6 +52,7 @@ metadata:
|
|
51
52
|
homepage_uri: http://appydave.com/gems/k-util
|
52
53
|
source_code_uri: https://github.com/klueless-io/k_util
|
53
54
|
changelog_uri: https://github.com/klueless-io/k_util/commits/master
|
55
|
+
rubygems_mfa_required: 'true'
|
54
56
|
post_install_message:
|
55
57
|
rdoc_options: []
|
56
58
|
require_paths:
|
@@ -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.
|
71
|
+
rubygems_version: 3.1.6
|
70
72
|
signing_key:
|
71
73
|
specification_version: 4
|
72
74
|
summary: KUtil provides simple utility methods
|