toolrack 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/README.md +8 -1
- data/lib/toolrack.rb +0 -5
- data/lib/toolrack/condition_utils.rb +3 -1
- data/lib/toolrack/process_utils.rb +9 -4
- data/lib/toolrack/runtime_utils.rb +1 -1
- data/lib/toolrack/utils.rb +23 -0
- data/lib/toolrack/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b1faebd0b9013273d3b9943462bcd01efacde8a688e2fe94743628b3d8c249e
|
4
|
+
data.tar.gz: af51abbaf1376b8cf2fadd1df32b6395609ecc237554803c562a661e365e9eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4374ec558bed30fff9ee2578169fa832f28668dc43ebeaab5ce3f651f97b6bb8870ba4f2cfb3cf6500ad49e7dc3a64ace2904fad23399e509e13a19b1c1306a9
|
7
|
+
data.tar.gz: cd45d0a0f890212298030dc1574fe900ccd13ae6b64bf7d57bce863ec7950e65d34238a6f8dedaabab0fadf04b9bf3e1defa4b2d47912e1285c6dd0756db7c1e
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -43,9 +43,10 @@ class EditController
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
-
Currently it has
|
46
|
+
Currently it has 3 modules:
|
47
47
|
* Condition Utilities
|
48
48
|
* is_empty?(obj) - I find rather effort intensive to call if not (obj.nil? or obj.empty?) for items that I want to check for validity before process. Hence this method shall test for .nil?. If the object also respond to :empty? it shall be called again. For example integer type does not support .empty?
|
49
|
+
* not_empty?(obj) - Reverse of the is\_empty?(obj) above
|
49
50
|
|
50
51
|
* Exception Utilities
|
51
52
|
* raise_if_empty(obj, message, error) - Extension from the is_empty?() above, usually if it is empty, an exception shall be raised. It is just combined the conditions with raise of exception.
|
@@ -55,6 +56,12 @@ Currently it has only 2 modules:
|
|
55
56
|
* raise_if_false(obj, message, error) - As the name implied
|
56
57
|
* raise_if_true(obj, message, error) - As the name implied
|
57
58
|
|
59
|
+
* Process Utilities
|
60
|
+
* exec(command, options = { ), &block) - Passing in the command into the method and result is returned to caller. If options is not given shall go to basic execution which is the backtick (\`). If block empty, result of the command is returned to caller. If block is given, result (true or false of the execution of command and any result from STDOUT is call to block provider(e.g. block.call($?, result)
|
61
|
+
|
62
|
+
# Note on Process Utilities
|
63
|
+
|
64
|
+
The command is passed as it is to the operating system which includes fatal operation such as "rm -rf". Library at current stage made no filtering on system harmful command hence the caller of the library has to take extra precaution on what command is being passed into the library
|
58
65
|
|
59
66
|
|
60
67
|
|
data/lib/toolrack.rb
CHANGED
@@ -23,7 +23,7 @@ module Antrapol
|
|
23
23
|
case type
|
24
24
|
when :basic
|
25
25
|
Antrapol::ToolRack::Logger.instance.glogger.debug "Basic execution"
|
26
|
-
basic_exec(cmd)
|
26
|
+
basic_exec(cmd, &block)
|
27
27
|
when :system
|
28
28
|
Antrapol::ToolRack::Logger.instance.glogger.debug "System execution"
|
29
29
|
system_exec(cmd, opts, &block)
|
@@ -33,7 +33,7 @@ module Antrapol
|
|
33
33
|
else
|
34
34
|
Antrapol::ToolRack::Logger.instance.glogger.debug "Basic (fallback) execution"
|
35
35
|
# basic
|
36
|
-
basic_exec(cmd)
|
36
|
+
basic_exec(cmd, &block)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -41,9 +41,14 @@ module Antrapol
|
|
41
41
|
# backtick
|
42
42
|
# backtick will only return at the end of the process.
|
43
43
|
# If in the event there is a prompt to user, this should nto be used.
|
44
|
-
def basic_exec(cmd)
|
44
|
+
def basic_exec(cmd, &block)
|
45
45
|
Antrapol::ToolRack::Logger.instance.glogger.debug "Basic shell exec command : #{cmd}"
|
46
|
-
`#{cmd}`
|
46
|
+
res = `#{cmd}`
|
47
|
+
if block
|
48
|
+
block.call($?, res)
|
49
|
+
else
|
50
|
+
res
|
51
|
+
end
|
47
52
|
end # basic_shell_exec
|
48
53
|
|
49
54
|
# system
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Antrapol
|
5
|
+
module Utils
|
6
|
+
|
7
|
+
def set_session_exception(exp)
|
8
|
+
if not exp.nil?
|
9
|
+
@sExp = exp
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def session_exception
|
14
|
+
if not @sExp.nil?
|
15
|
+
@sExcp
|
16
|
+
else
|
17
|
+
Antrapol::ToolRack::Error
|
18
|
+
end
|
19
|
+
end
|
20
|
+
alias_method :session_exception, :s_exp
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/toolrack/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tlogger
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- lib/toolrack/exception_utils.rb
|
45
45
|
- lib/toolrack/process_utils.rb
|
46
46
|
- lib/toolrack/runtime_utils.rb
|
47
|
+
- lib/toolrack/utils.rb
|
47
48
|
- lib/toolrack/version.rb
|
48
49
|
- process_test/backtick_test.rb
|
49
50
|
- process_test/pty_test.rb
|