k_util 0.0.26 → 0.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/Gemfile +1 -1
- data/hooks/update-version +1 -1
- data/k_util.gemspec +4 -3
- data/lib/k_util/data/instance_variables_to_h.rb +6 -2
- data/lib/k_util/open3_helper.rb +3 -2
- data/lib/k_util/version.rb +1 -1
- data/lib/k_util.rb +1 -2
- metadata +4 -4
- data/lib/k_util/data/instance_variables_to_symbolized_hash.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9ec8fb313e3972467b61761e295e19d5d51cd0f9588b8c905b7c5f1ed764dfe
|
4
|
+
data.tar.gz: aaecd737aaaca075c1226b5a49a16f72cc95c3478a04ad93fefd3990def1c8af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00b1b9528aa4bfc8cca63dcefe68a943e2f5fcd4ee413d7f05e28630e4dbb411d969f07fd579e30491ed2d4b1a384f09acef81c00d50882320be4c658be2f033
|
7
|
+
data.tar.gz: cd878a71496b9e2f7b5ff415bfb31b931affd0b44870ab0d7b9690cf465caee99a020c14e0158510a32e8431274b409acb56d58d631c91e7616b58ef4e3e8b3e
|
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
@@ -22,9 +22,10 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
# spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
|
24
24
|
|
25
|
-
spec.metadata['homepage_uri']
|
26
|
-
spec.metadata['source_code_uri']
|
27
|
-
spec.metadata['changelog_uri']
|
25
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
26
|
+
spec.metadata['source_code_uri'] = 'https://github.com/klueless-io/k_util'
|
27
|
+
spec.metadata['changelog_uri'] = 'https://github.com/klueless-io/k_util/commits/master'
|
28
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
28
29
|
|
29
30
|
# Specify which files should be added to the gem when it is released.
|
30
31
|
# The `git ls-files -z` loads the RubyGem files that have been added into git.
|
@@ -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
|
-
|
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
|
data/lib/k_util/open3_helper.rb
CHANGED
@@ -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
|
-
|
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?
|
data/lib/k_util/version.rb
CHANGED
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'
|
@@ -28,7 +27,7 @@ module KUtil
|
|
28
27
|
KUtil.open3 = KUtil::Open3Helper.new
|
29
28
|
end
|
30
29
|
|
31
|
-
if ENV
|
30
|
+
if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
|
32
31
|
namespace = 'KUtil::Version'
|
33
32
|
file_path = $LOADED_FEATURES.find { |f| f.include?('k_util/version') }
|
34
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.29
|
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-
|
11
|
+
date: 2022-07-14 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
|
@@ -53,6 +52,7 @@ metadata:
|
|
53
52
|
homepage_uri: http://appydave.com/gems/k-util
|
54
53
|
source_code_uri: https://github.com/klueless-io/k_util
|
55
54
|
changelog_uri: https://github.com/klueless-io/k_util/commits/master
|
55
|
+
rubygems_mfa_required: 'true'
|
56
56
|
post_install_message:
|
57
57
|
rdoc_options: []
|
58
58
|
require_paths:
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.1.6
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: KUtil provides simple utility methods
|
@@ -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
|