cmd2json 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cmd2json.rb +12 -3
- data/lib/cmd2json/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: becb4451af48f24199de8e1baf36a6e11c5229f3
|
4
|
+
data.tar.gz: e340d7d38551c3f87aca4a5ccb383c3f0038e246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 025c6cbe443c4d634569e8793dcc659844e16a965dae6646a82ac42dd5bdd3c99513c885165031fd892e18542ad34cd02b84ec67948105827148bfee64de22a4
|
7
|
+
data.tar.gz: 00c255acec0f3362ea3540306c594099854c89a554e8df59202197b15b79d575ee4ace9f6f95534bba9adedfa0fa4ca0994ff8f4439dabce7525b99fb2fee528
|
data/lib/cmd2json.rb
CHANGED
@@ -3,14 +3,23 @@ require 'socket'
|
|
3
3
|
|
4
4
|
module Cmd2Json
|
5
5
|
def self.run(argv, options={})
|
6
|
+
out = ""
|
6
7
|
begin
|
7
|
-
out = ""
|
8
8
|
IO.popen(argv, err: [:child, :out]) { |io| out = io.read }
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
# log when subprocess was killed, need manual testing as integration test
|
11
|
+
unless status = $?.exitstatus
|
12
|
+
out << "\nKilled"
|
13
|
+
status = 1
|
14
|
+
end
|
15
|
+
rescue Errno::ENOENT # executable not found
|
11
16
|
out = $!.message
|
12
17
|
status = 1
|
18
|
+
rescue SignalException # need manual testing as integration test
|
19
|
+
out << "\nKilled #{$!}"
|
20
|
+
status = 1
|
13
21
|
end
|
22
|
+
|
14
23
|
result = {message: out, exit: status}
|
15
24
|
result['@timestamp'] = Time.now if options[:timestamp]
|
16
25
|
result[:host] = Socket.gethostname if options[:host]
|
data/lib/cmd2json/version.rb
CHANGED