toolrack 0.16.1 → 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.release_history.yml +10 -0
- data/Gemfile.lock +72 -0
- data/lib/toolrack/block_params_utils.rb +40 -0
- data/lib/toolrack/condition_utils.rb +24 -4
- data/lib/toolrack/file_utils.rb +72 -0
- data/lib/toolrack/runtime_utils.rb +4 -0
- data/lib/toolrack/version.rb +1 -1
- data/lib/toolrack.rb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a00f7d861b86b8ca872b38444ea1a35af38230cf8fa8209df9bf0d3da4f3994
|
4
|
+
data.tar.gz: 69d6ee0f0061af4604d3946a78fbcfcc1757d3aa3d515c07598be6678dfefce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aa3113f5e213cc31dddffc6a3e6049406c93ca4a18be72051f98cbc7b0e341978fc4c868e54386db7e8d55921c04d7af12279c3bdfad9d7ca9d0fb8f81caa86
|
7
|
+
data.tar.gz: 1d8dd5997762768adb972de3a59c91b1fc3c52460c64ccc6d5c2eba79dd15a73fe159ca31f3686088d37dfd600cfa55672d5c5ff7259be1af88694ebe88bad7f
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
toolrack (0.17.0)
|
5
|
+
base58
|
6
|
+
tlogger
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
base58 (0.2.3)
|
12
|
+
devops_assist (0.1.4)
|
13
|
+
git_cli
|
14
|
+
git_cli_prompt
|
15
|
+
gvcs
|
16
|
+
tlogger
|
17
|
+
toolrack
|
18
|
+
tty-prompt
|
19
|
+
diff-lcs (1.4.4)
|
20
|
+
git_cli (0.9.0)
|
21
|
+
gvcs
|
22
|
+
ptools (~> 1.4.0)
|
23
|
+
tlogger
|
24
|
+
toolrack
|
25
|
+
git_cli_prompt (0.2.2)
|
26
|
+
tlogger
|
27
|
+
toolrack
|
28
|
+
tty-prompt
|
29
|
+
gvcs (0.1.0)
|
30
|
+
minitest (5.14.4)
|
31
|
+
pastel (0.8.0)
|
32
|
+
tty-color (~> 0.5)
|
33
|
+
ptools (1.4.2)
|
34
|
+
rake (12.3.3)
|
35
|
+
rspec (3.10.0)
|
36
|
+
rspec-core (~> 3.10.0)
|
37
|
+
rspec-expectations (~> 3.10.0)
|
38
|
+
rspec-mocks (~> 3.10.0)
|
39
|
+
rspec-core (3.10.1)
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-expectations (3.10.1)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-mocks (3.10.2)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-support (3.10.3)
|
48
|
+
tlogger (0.26.3)
|
49
|
+
tty-color (0.6.0)
|
50
|
+
tty-cursor (0.7.1)
|
51
|
+
tty-prompt (0.23.1)
|
52
|
+
pastel (~> 0.8)
|
53
|
+
tty-reader (~> 0.8)
|
54
|
+
tty-reader (0.9.0)
|
55
|
+
tty-cursor (~> 0.7)
|
56
|
+
tty-screen (~> 0.8)
|
57
|
+
wisper (~> 2.0)
|
58
|
+
tty-screen (0.8.1)
|
59
|
+
wisper (2.0.1)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
x86_64-linux
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
devops_assist
|
66
|
+
minitest (~> 5.0)
|
67
|
+
rake (~> 12.0)
|
68
|
+
rspec
|
69
|
+
toolrack!
|
70
|
+
|
71
|
+
BUNDLED WITH
|
72
|
+
2.2.22
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Antrapol
|
5
|
+
module ToolRack
|
6
|
+
module BlockParamsUtils
|
7
|
+
include ConditionUtils
|
8
|
+
|
9
|
+
def value_from_block(blockKey, defValue, opts = { }, &block)
|
10
|
+
if block
|
11
|
+
blockParams = nil
|
12
|
+
if not_empty?(opts)
|
13
|
+
blockParams = opts[:blockArgs]
|
14
|
+
end
|
15
|
+
|
16
|
+
value = nil
|
17
|
+
if blockParams.nil?
|
18
|
+
value = block.call(blockKey)
|
19
|
+
value = defValue if is_empty?(value)
|
20
|
+
else
|
21
|
+
value = block.call(blockKey, *blockParams)
|
22
|
+
value = defValue if is_empty?(value)
|
23
|
+
end
|
24
|
+
|
25
|
+
value
|
26
|
+
else
|
27
|
+
defValue
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def self.included(klass)
|
33
|
+
klass.class_eval <<-END
|
34
|
+
extend Antrapol::ToolRack::BlockParamsUtils
|
35
|
+
END
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -10,11 +10,24 @@ module Antrapol
|
|
10
10
|
elsif obj.nil?
|
11
11
|
true
|
12
12
|
elsif obj.respond_to?(:empty?)
|
13
|
-
|
14
|
-
obj.strip
|
15
|
-
|
16
|
-
|
13
|
+
begin
|
14
|
+
if obj.respond_to?(:strip)
|
15
|
+
obj.strip.empty?
|
16
|
+
else
|
17
|
+
obj.empty?
|
18
|
+
end
|
19
|
+
rescue ArgumentError => ex
|
20
|
+
# strip sometimes trigger 'invalid byte sequence in UTF-8' error
|
21
|
+
# This will happen if the data is binary but the reading of the data
|
22
|
+
# is in ascii format.
|
23
|
+
if ex.message =~ /invalid byte sequence/
|
24
|
+
cuLogger.twarn :is_empty?, "Invalid byte sequence exception might indicates the data is expected in binary but was given a ASCII buffer to test. Please load the data in binary and test again"
|
25
|
+
false
|
26
|
+
else
|
27
|
+
raise
|
28
|
+
end
|
17
29
|
end
|
30
|
+
|
18
31
|
elsif obj.respond_to?(:length)
|
19
32
|
obj.length == 0
|
20
33
|
elsif obj.respond_to?(:size)
|
@@ -48,6 +61,13 @@ module Antrapol
|
|
48
61
|
end
|
49
62
|
alias_method :is_str_bool?, :is_string_boolean?
|
50
63
|
|
64
|
+
def cuLogger
|
65
|
+
if @cuLogger.nil?
|
66
|
+
@cuLogger = Tlogger.new
|
67
|
+
end
|
68
|
+
@cuLogger
|
69
|
+
end
|
70
|
+
|
51
71
|
#
|
52
72
|
# Make it available at class level too
|
53
73
|
#
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
module Antrapol
|
5
|
+
module ToolRack
|
6
|
+
module FileUtils
|
7
|
+
include Antrapol::ToolRack::DataConversionUtils
|
8
|
+
|
9
|
+
class FileUtilsError < StandardError; end
|
10
|
+
module ClassMethods
|
11
|
+
def is_same?(*args, &block)
|
12
|
+
opts = { verbose: false }
|
13
|
+
if args.last.is_a?(Hash)
|
14
|
+
opts.merge!(args.last)
|
15
|
+
target = args[0..-2]
|
16
|
+
else
|
17
|
+
target = args
|
18
|
+
end
|
19
|
+
|
20
|
+
raise FileUtilsError, "is_same? requires at least 2 files" if target.length < 2
|
21
|
+
|
22
|
+
res = true
|
23
|
+
size = nil
|
24
|
+
target.each do |f|
|
25
|
+
raise FileUtilsError, "Given file #{f} to is_same? does not exist" if not File.exist?(f)
|
26
|
+
|
27
|
+
if size.nil?
|
28
|
+
size = File.size(f)
|
29
|
+
elsif File.size(f) != size
|
30
|
+
res = false
|
31
|
+
break
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
if res
|
37
|
+
prevDigRes = nil
|
38
|
+
target.each do |f|
|
39
|
+
dig = OpenSSL::Digest.new("SHA256")
|
40
|
+
bufSize = 2048*1000
|
41
|
+
File.open(f,"rb") do |f|
|
42
|
+
dig.update(f.read(bufSize))
|
43
|
+
end
|
44
|
+
digRes = dig.digest
|
45
|
+
|
46
|
+
STDOUT.puts "#{f} : #{to_hex(digRes)}" if opts[:verbose]
|
47
|
+
|
48
|
+
if prevDigRes.nil?
|
49
|
+
prevDigRes = digRes
|
50
|
+
elsif prevDigRes != digRes
|
51
|
+
res = false
|
52
|
+
break
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
res
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.included(klass)
|
63
|
+
File.class_eval <<-END
|
64
|
+
extend Antrapol::ToolRack::FileUtils::ClassMethods
|
65
|
+
END
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
data/lib/toolrack/version.rb
CHANGED
data/lib/toolrack.rb
CHANGED
@@ -16,6 +16,8 @@ require_relative 'toolrack/hash_config'
|
|
16
16
|
require_relative 'toolrack/cli_utils'
|
17
17
|
require_relative 'toolrack/null_output'
|
18
18
|
require_relative 'toolrack/version_utils'
|
19
|
+
require_relative 'toolrack/file_utils'
|
20
|
+
require_relative 'toolrack/block_params_utils'
|
19
21
|
|
20
22
|
module Antrapol
|
21
23
|
module ToolRack
|
@@ -59,3 +61,7 @@ TR::NullOut = ToolRack::NullOutput
|
|
59
61
|
TR::VerUtils = ToolRack::VersionUtils
|
60
62
|
TR::VUtils = TR::VerUtils
|
61
63
|
|
64
|
+
TR::FileUtils = ToolRack::FileUtils
|
65
|
+
|
66
|
+
TR::BlockParamsUtils = ToolRack::BlockParamsUtils
|
67
|
+
|
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.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tlogger
|
@@ -74,19 +74,23 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".release_history.yml"
|
77
78
|
- ".rspec"
|
78
79
|
- ".travis.yml"
|
79
80
|
- CODE_OF_CONDUCT.md
|
80
81
|
- Gemfile
|
82
|
+
- Gemfile.lock
|
81
83
|
- README.md
|
82
84
|
- Rakefile
|
83
85
|
- bin/console
|
84
86
|
- bin/setup
|
85
87
|
- lib/toolrack.rb
|
88
|
+
- lib/toolrack/block_params_utils.rb
|
86
89
|
- lib/toolrack/cli_utils.rb
|
87
90
|
- lib/toolrack/condition_utils.rb
|
88
91
|
- lib/toolrack/data_conversion_utils.rb
|
89
92
|
- lib/toolrack/exception_utils.rb
|
93
|
+
- lib/toolrack/file_utils.rb
|
90
94
|
- lib/toolrack/global.rb
|
91
95
|
- lib/toolrack/hash_config.rb
|
92
96
|
- lib/toolrack/null_output.rb
|