k_util 0.0.25 → 0.0.28

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: 56357183b8ad499df1c975d89323ccadb36320ca5bd0dd8fa32b45189cd50ed8
4
+ data.tar.gz: 8febfec303b8f12ab406b141141e05df8f5110db0425cccf2b27d429a0b1f26a
5
5
  SHA512:
6
- metadata.gz: 483f2ef0d30165c68f5cad6cd0f1acd199a07ac44fedace7ffe5195c581159f020bb5847a6f009c4a732fac51f8d80c550352ebb4c46430e64521f7b99de4ecb
7
- data.tar.gz: de0d1b1776acc57acc51f981dce2ac8c1c4b3a0504db0f4a1c18ba7b49fc6344080aed9532d93ac515d9bb141c60f202ec3d5e8638d82fe33c5b185cc1b98903
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
- IgnoredPatterns: ['\A# \*\*']
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
@@ -16,7 +16,7 @@ group :development, :test do
16
16
  gem 'guard-bundler'
17
17
  gem 'guard-rspec'
18
18
  gem 'guard-rubocop'
19
- gem 'rake', '~> 12.0'
19
+ gem 'rake'
20
20
  gem 'rake-compiler', require: false
21
21
  gem 'rspec', '~> 3.0'
22
22
  gem 'rubocop'
data/hooks/update-version CHANGED
@@ -30,4 +30,4 @@ end
30
30
  output.push('')
31
31
 
32
32
  printf "%-25<label>s : %<version>s\n", label: 'GEM VERSION', version: version
33
- File.open('lib/k_util/version.rb', 'w+') { |f| f.write(output.join("\n")) }
33
+ File.write('lib/k_util/version.rb', output.join("\n"))
data/k_util.gemspec CHANGED
@@ -39,4 +39,5 @@ Gem::Specification.new do |spec|
39
39
  # spec.extensions = ['ext/k_util/extconf.rb']
40
40
 
41
41
  # spec.add_dependency 'tty-box', '~> 0.5.0'
42
+ spec.metadata['rubygems_mfa_required'] = 'true'
42
43
  end
@@ -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
- 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
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
@@ -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.28'
5
5
  end
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::Error, 'Sample message'
12
- # class Error < StandardError; end
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['KLUE_DEBUG']&.to_s&.downcase == 'true'
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.25
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: 2021-12-13 00:00:00.000000000 Z
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.2.7
71
+ rubygems_version: 3.1.6
70
72
  signing_key:
71
73
  specification_version: 4
72
74
  summary: KUtil provides simple utility methods