execute 0.1.5 → 0.1.7
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 +4 -4
- data/lib/cmd.rb +7 -8
- 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: 136de8d8682549cc6430b228c3fe34e3bd646b33
|
4
|
+
data.tar.gz: 17ddeb504dc69715e9b9c7421f04175b41d692fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7933e383171891718afadc1714df073eced3a477cd1fb72ca091fe2fd1b46568399468e01bba032a5e34e06fe33cc35d6aa006336edf5848cd67922fb7bb50
|
7
|
+
data.tar.gz: afafb75f9ce9204fc9740fe2ef83c2bfc6b82c1c5c9eec441418eee3ceb60184248551f77211580de75f168cfa983b88fc28dc77049d419d2374ee8cb733b8cd
|
data/lib/cmd.rb
CHANGED
@@ -4,12 +4,8 @@ require_relative 'IOAdapter.rb'
|
|
4
4
|
|
5
5
|
class CMD < Hash
|
6
6
|
private
|
7
|
-
@@default_options =
|
7
|
+
@@default_options = { echo_command: true, echo_output: true, ignore_exit_code: false, debug: false }
|
8
8
|
|
9
|
-
def initialize_defaults
|
10
|
-
@@default_options = { echo_command: true, echo_output: true, ignore_exit_code: false, debug: false }
|
11
|
-
end
|
12
|
-
|
13
9
|
public
|
14
10
|
def initialize(cmd, options=nil)
|
15
11
|
initialize_defaults if(@@default_options.nil?)
|
@@ -23,12 +19,11 @@ class CMD < Hash
|
|
23
19
|
|
24
20
|
public
|
25
21
|
def self.default_options(hash)
|
26
|
-
initialize_defaults
|
27
22
|
hash.each { |key, value| @@default_options[key] = value}
|
28
23
|
end
|
29
24
|
|
30
25
|
def execute
|
31
|
-
|
26
|
+
begin
|
32
27
|
puts self[:command] if(self[:echo_command])
|
33
28
|
|
34
29
|
output = {output: [], error: [] }
|
@@ -46,7 +41,11 @@ class CMD < Hash
|
|
46
41
|
self[:error] = output[:error].join
|
47
42
|
self[:exit_code] = wait_thr.value.to_i
|
48
43
|
end
|
49
|
-
|
44
|
+
rescue Excpetion => e
|
45
|
+
self[:error] = "#{self[:error]}\nException: #{e.to_s}"
|
46
|
+
self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
|
47
|
+
end
|
48
|
+
|
50
49
|
if(self[:debug])
|
51
50
|
puts "command: #{self[:command]}" if(self[:quiet])
|
52
51
|
puts "output: #{self[:output]}"
|