toolrack 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toolrack/cli_utils.rb +30 -0
- data/lib/toolrack/exception_utils.rb +5 -5
- data/lib/toolrack/version.rb +1 -1
- data/lib/toolrack.rb +4 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 518ddfe481fa191f172644095ba791c7b07d9416bd2923beaed87555c2d13d19
|
4
|
+
data.tar.gz: e0d91b53caaa6f2f6503a659851c575d9ef89782a5b461c4d3b209775a7a9863
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 424084db4af22765dae792d22c6b0f47ad5836a30d883319686c04ab5296a13e71db1a4d2d85d35c0833c764e21b0d95cc2dc0c6e147e15cbfd0c08a7f694c25
|
7
|
+
data.tar.gz: 24dfcaacfde2b1423e2407c38c519b5ff0c4bb2fce1d7f497b856bd003dc61df0e25933d297716ab990d59e1a80d55d55a8a69c95a0fb5c02d835e1a013a8131
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
require 'pty'
|
3
|
+
require 'expect'
|
4
|
+
|
5
|
+
module Antrapol
|
6
|
+
module ToolRack
|
7
|
+
module CliUtils
|
8
|
+
include Antrapol::ToolRack::ConditionUtils
|
9
|
+
|
10
|
+
class CliUtilsError < StandardError; end
|
11
|
+
|
12
|
+
def which(app)
|
13
|
+
if not_empty?(app)
|
14
|
+
path = `which #{app}`
|
15
|
+
path.strip if not_empty?(path)
|
16
|
+
else
|
17
|
+
raise CliUtilsError, "Given appication to look for full path (which) is empty"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def self.included(klass)
|
23
|
+
klass.class_eval <<-END
|
24
|
+
extend Antrapol::ToolRack::CliUtils
|
25
|
+
END
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
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 =
|
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 =
|
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 =
|
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 =
|
38
|
+
def raise_error(message, error = StandardError)
|
39
39
|
if error.nil?
|
40
40
|
if @default_exception.nil?
|
41
|
-
raise
|
41
|
+
raise StandardError, message
|
42
42
|
else
|
43
43
|
raise @default_exception, message
|
44
44
|
end
|
data/lib/toolrack/version.rb
CHANGED
data/lib/toolrack.rb
CHANGED
@@ -13,6 +13,7 @@ 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'
|
16
17
|
|
17
18
|
module Antrapol
|
18
19
|
module ToolRack
|
@@ -26,6 +27,7 @@ module TR
|
|
26
27
|
Antrapol::ToolRack
|
27
28
|
end
|
28
29
|
|
30
|
+
# aliases
|
29
31
|
ToolRack = Antrapol::ToolRack
|
30
32
|
#TR = ToolRack
|
31
33
|
|
@@ -46,3 +48,5 @@ TR::RTUtils = ToolRack::RTUtils
|
|
46
48
|
|
47
49
|
TR::HashConfig = ToolRack::HashConfig
|
48
50
|
|
51
|
+
TR::CliUtils = ToolRack::CliUtils
|
52
|
+
|
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.14.0
|
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-
|
11
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tlogger
|
@@ -83,6 +83,7 @@ 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
|
@@ -103,7 +104,7 @@ licenses: []
|
|
103
104
|
metadata:
|
104
105
|
homepage_uri: https://github.com/chrisliaw/toolrack
|
105
106
|
source_code_uri: https://github.com/chrisliaw/toolrack
|
106
|
-
post_install_message:
|
107
|
+
post_install_message:
|
107
108
|
rdoc_options: []
|
108
109
|
require_paths:
|
109
110
|
- lib
|
@@ -119,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
122
|
rubygems_version: 3.2.22
|
122
|
-
signing_key:
|
123
|
+
signing_key:
|
123
124
|
specification_version: 4
|
124
125
|
summary: Collection of simple utilities but I find it increase clarity
|
125
126
|
test_files: []
|