toolrack 0.13.0 → 0.16.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8dd55a26c516a19fa866167542d1654ad82e8bd004eb099898030ee72b3128f
4
- data.tar.gz: 28e576da345ff8e9d43e4e890cbb1ce66b7d896740a22e62693b7b1e8f17cbb5
3
+ metadata.gz: 1c9837dac71c7f526258e7cf66181000d4fd9c005431a630b60cfbf607991314
4
+ data.tar.gz: 586c74cdceff146ff2cc5efdb6a4927ed451c79d81107efe7a97eb4405ef22ab
5
5
  SHA512:
6
- metadata.gz: 23af16b224d1fed00c2cf4b9e9649ec7c3c6438ab2309f193a61f15eed06c556a6176b94bcb87bbadf32d81f3cd9008d43610d896c05a2f0ad8dccc41668a589
7
- data.tar.gz: 87e16f2c2a2761c229bbe979960b2bf58c05e5712d351ad2b148569f426e6a628720ee5a39de647d428ab51bfceb249ca5ceb7a1f8c1aaa002b16210973b7775
6
+ metadata.gz: f6cc439cfab0dd18eafe8bb88412dcc3cf16fd077f87e7885b396fb8f460597eba106aa4c8873c9b31fa72ec34cbe3caa09d56f8ede02eb2a399b6ae9ad61569
7
+ data.tar.gz: a6c3738f458eedb868baae78c61ecb98ef1445a43e9bc2a78ee1ad1de19630a9455d93ddd150832f04cf252d5ac001edd451518307b1ebd103fc26c51f7a13fb
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
- require 'devops_helper'
4
+ require 'devops_assist'
5
5
 
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
@@ -0,0 +1,28 @@
1
+
2
+
3
+ module Antrapol
4
+ module ToolRack
5
+ module CliUtils
6
+ include Antrapol::ToolRack::ConditionUtils
7
+
8
+ class CliUtilsError < StandardError; end
9
+
10
+ def which(app)
11
+ if not_empty?(app)
12
+ path = `which #{app}`
13
+ path.strip if not_empty?(path)
14
+ else
15
+ raise CliUtilsError, "Given appication to look for full path (which) is empty"
16
+ end
17
+ end
18
+
19
+
20
+ def self.included(klass)
21
+ klass.class_eval <<-END
22
+ extend Antrapol::ToolRack::CliUtils
23
+ END
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -48,6 +48,9 @@ module Antrapol
48
48
  end
49
49
  alias_method :is_str_bool?, :is_string_boolean?
50
50
 
51
+ #
52
+ # Make it available at class level too
53
+ #
51
54
  def self.included(klass)
52
55
  klass.class_eval <<-END
53
56
  extend Antrapol::ToolRack::ConditionUtils
@@ -115,6 +115,18 @@ module Antrapol
115
115
  alias_method :str_to_bool, :string_to_bool
116
116
  alias_method :string_to_boolean, :string_to_bool
117
117
 
118
+
119
+
120
+ #
121
+ # Make it available at class level too
122
+ #
123
+ def self.included(klass)
124
+ klass.class_eval <<-END
125
+ extend Antrapol::ToolRack::DataConversionUtils
126
+ END
127
+ end
128
+
129
+
118
130
  end
119
131
  end
120
132
  end
@@ -11,7 +11,7 @@ module Antrapol
11
11
  # val - variable/object that shall be tested for emptiness
12
12
  # message - message to be thrown if it is true
13
13
  # error - exception object to be thrown
14
- def raise_if_empty(val, message, error = Antrapol::ToolRack::Error)
14
+ def raise_if_empty(val, message, error = StandardError)
15
15
  raise_error(message,error) if is_empty?(val)
16
16
  end # raise_if_empty
17
17
  alias_method :raise_if_empty?, :raise_if_empty
@@ -19,7 +19,7 @@ module Antrapol
19
19
  #
20
20
  # raise_if_false
21
21
  #
22
- def raise_if_false(bool, message, error = Antrapol::ToolRack::Error)
22
+ def raise_if_false(bool, message, error = StandardError)
23
23
  if not bool
24
24
  raise_error(message,error)
25
25
  end
@@ -29,16 +29,16 @@ module Antrapol
29
29
  #
30
30
  # raise_if_true
31
31
  #
32
- def raise_if_true(bool, message, error = Antrapol::ToolRack::Error)
32
+ def raise_if_true(bool, message, error = StandardError)
33
33
  raise_if_false(!bool, message, error)
34
34
  end # raise_if_true
35
35
  alias_method :raise_if_true?, :raise_if_true
36
36
 
37
37
  protected
38
- def raise_error(message, error = Antrapol::ToolRack::Error)
38
+ def raise_error(message, error = StandardError)
39
39
  if error.nil?
40
40
  if @default_exception.nil?
41
- raise Antrapol::ToolRack::Error, message
41
+ raise StandardError, message
42
42
  else
43
43
  raise @default_exception, message
44
44
  end
@@ -0,0 +1,22 @@
1
+
2
+
3
+ module Antrapol
4
+ module ToolRack
5
+ class NullOutput
6
+
7
+ def method_missing(mtd, *args, &block)
8
+ # sink-holed all methods call
9
+ logger.tdebug :nullOut, "#{mtd} / #{args} / #{block ? "with block" : "no block"}"
10
+ end
11
+
12
+ private
13
+ def logger
14
+ if @logger.nil?
15
+ @logger = Tlogger.new
16
+ end
17
+ @logger
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -1,6 +1,6 @@
1
1
  module Antrapol
2
2
  module ToolRack
3
- VERSION = "0.13.0"
3
+ VERSION = "0.16.1"
4
4
  end
5
5
  end
6
6
 
@@ -0,0 +1,47 @@
1
+
2
+ require_relative 'condition_utils'
3
+
4
+ module Antrapol
5
+ module ToolRack
6
+ module VersionUtils
7
+ include Antrapol::ToolRack::ConditionUtils
8
+
9
+ class VersionUtilsError < StandardError; end
10
+
11
+ def is_version_equal?(*args)
12
+ res = true
13
+ target = Gem::Version.new(args.first)
14
+ args.each do |a|
15
+ subj = Gem::Version.new(a)
16
+ res = (subj == target)
17
+ break if not res
18
+ target = subj
19
+ end
20
+
21
+ res
22
+ end
23
+
24
+ def possible_versions(ver)
25
+ raise VersionUtilsError, "Given version to extrapolate is empty" if is_empty?(ver)
26
+ vv = ver.to_s.split('.')
27
+ tv = vv.clone
28
+ res = []
29
+ cnt = 0
30
+ (0...vv.length).each do |i|
31
+ tv = vv.clone
32
+ tv[i] = tv[i].to_i+1
33
+
34
+ j = i
35
+ loop do
36
+ break if j >= (vv.length-1)
37
+ j += 1
38
+ tv[j] = 0
39
+ end
40
+ res << tv.join(".")
41
+ end
42
+ res
43
+ end
44
+
45
+ end
46
+ end
47
+ end
data/lib/toolrack.rb CHANGED
@@ -13,6 +13,9 @@ require_relative 'toolrack/runtime_utils'
13
13
  require_relative 'toolrack/data_conversion_utils'
14
14
  require_relative 'toolrack/password_utils'
15
15
  require_relative 'toolrack/hash_config'
16
+ require_relative 'toolrack/cli_utils'
17
+ require_relative 'toolrack/null_output'
18
+ require_relative 'toolrack/version_utils'
16
19
 
17
20
  module Antrapol
18
21
  module ToolRack
@@ -26,6 +29,7 @@ module TR
26
29
  Antrapol::ToolRack
27
30
  end
28
31
 
32
+ # aliases
29
33
  ToolRack = Antrapol::ToolRack
30
34
  #TR = ToolRack
31
35
 
@@ -35,6 +39,8 @@ TR::DataConvUtils = ToolRack::DataConvUtils
35
39
  ToolRack::CondUtils = ToolRack::ConditionUtils
36
40
  TR::CondUtils = ToolRack::ConditionUtils
37
41
 
42
+ TR::ProcessUtils = ToolRack::ProcessUtils
43
+
38
44
  ToolRack::PassUtils = ToolRack::PasswordUtils
39
45
  TR::PassUtils = ToolRack::PasswordUtils
40
46
 
@@ -46,3 +52,10 @@ TR::RTUtils = ToolRack::RTUtils
46
52
 
47
53
  TR::HashConfig = ToolRack::HashConfig
48
54
 
55
+ TR::CliUtils = ToolRack::CliUtils
56
+
57
+ TR::NullOut = ToolRack::NullOutput
58
+
59
+ TR::VerUtils = ToolRack::VersionUtils
60
+ TR::VUtils = TR::VerUtils
61
+
data/toolrack.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "tlogger" #, "~> 0.21"
30
30
  spec.add_dependency "base58"
31
31
 
32
- spec.add_development_dependency "devops_helper" #, "~> 0.1.0"
32
+ #spec.add_development_dependency "devops_helper" #, "~> 0.1.0"
33
+ spec.add_development_dependency "devops_assist"
33
34
  spec.add_development_dependency "rspec"
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toolrack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-10 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tlogger
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: devops_helper
42
+ name: devops_assist
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -83,16 +83,19 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/toolrack.rb
86
+ - lib/toolrack/cli_utils.rb
86
87
  - lib/toolrack/condition_utils.rb
87
88
  - lib/toolrack/data_conversion_utils.rb
88
89
  - lib/toolrack/exception_utils.rb
89
90
  - lib/toolrack/global.rb
90
91
  - lib/toolrack/hash_config.rb
92
+ - lib/toolrack/null_output.rb
91
93
  - lib/toolrack/password_utils.rb
92
94
  - lib/toolrack/process_utils.rb
93
95
  - lib/toolrack/runtime_utils.rb
94
96
  - lib/toolrack/utils.rb
95
97
  - lib/toolrack/version.rb
98
+ - lib/toolrack/version_utils.rb
96
99
  - process_test/backtick_test.rb
97
100
  - process_test/pty_test.rb
98
101
  - process_test/shell_test.rb
@@ -103,7 +106,7 @@ licenses: []
103
106
  metadata:
104
107
  homepage_uri: https://github.com/chrisliaw/toolrack
105
108
  source_code_uri: https://github.com/chrisliaw/toolrack
106
- post_install_message:
109
+ post_install_message:
107
110
  rdoc_options: []
108
111
  require_paths:
109
112
  - lib
@@ -119,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
122
  version: '0'
120
123
  requirements: []
121
124
  rubygems_version: 3.2.22
122
- signing_key:
125
+ signing_key:
123
126
  specification_version: 4
124
127
  summary: Collection of simple utilities but I find it increase clarity
125
128
  test_files: []