dev_commands 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/array.rb +1 -0
- data/lib/command.rb +23 -10
- data/spec/command_spec.rb +4 -0
- 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: 2bf6bd51e45b9c16b1389e81393dc5f7f3418936
|
4
|
+
data.tar.gz: 6629c5669dc7c52461e6be0836e729249d16819a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b406adf163157db56d19b808beb3ca512f2aceea9c763e6ac4b4c2b2dea29b6071a0b5cd876de2a052145a979e940a5920d6bc04ed3de2253deb4b427a41e83
|
7
|
+
data.tar.gz: ffdb1c0862886ce90d86299cc793b9b189737836c34f9e40513a56a1342a48041ef5df6ac3e6f524207fa6e0ff5a2c8b6b4f80a6211d54ef40bbed8d7a1d2525
|
data/lib/array.rb
CHANGED
data/lib/command.rb
CHANGED
@@ -6,17 +6,19 @@ require_relative('./timer.rb')
|
|
6
6
|
class Command < Hash
|
7
7
|
def initialize command
|
8
8
|
|
9
|
+
self[:input] = ''
|
10
|
+
self[:timeout] = 0
|
11
|
+
self[:directory] = ''
|
12
|
+
self[:exit_code] = 0
|
13
|
+
self[:output] = ''
|
14
|
+
self[:error] = ''
|
15
|
+
self[:machine] = ''
|
16
|
+
self[:user] = ''
|
17
|
+
self[:start_time] = nil
|
18
|
+
self[:end_time] = nil
|
19
|
+
|
9
20
|
if(command.kind_of?(String))
|
10
21
|
self[:input] = command
|
11
|
-
self[:timeout] = 0
|
12
|
-
self[:directory] = ''
|
13
|
-
self[:exit_code] = 0
|
14
|
-
self[:output] = ''
|
15
|
-
self[:error] = ''
|
16
|
-
self[:machine] = ''
|
17
|
-
self[:user] = ''
|
18
|
-
self[:start_time] = nil
|
19
|
-
self[:end_time] = nil
|
20
22
|
end
|
21
23
|
|
22
24
|
if(command.kind_of?(Hash))
|
@@ -53,7 +55,8 @@ class Command < Hash
|
|
53
55
|
self[:end_time] = Time.now
|
54
56
|
else
|
55
57
|
begin
|
56
|
-
self[:output],self[:error],
|
58
|
+
self[:output],self[:error],status= Open3.capture3(self[:input])
|
59
|
+
self[:exit_code]=status.to_i
|
57
60
|
self[:elapsed] = timer.elapsed_str
|
58
61
|
self[:end_time] = Time.now
|
59
62
|
#self[:exit_code]=$?.to_i
|
@@ -66,6 +69,16 @@ class Command < Hash
|
|
66
69
|
end
|
67
70
|
|
68
71
|
Dir.chdir(pwd) if pwd != Dir.pwd
|
72
|
+
|
73
|
+
if(self[:exit_code] != 0)
|
74
|
+
puts ' '
|
75
|
+
puts "exit_code=#{self[:exit_code]}"
|
76
|
+
puts ' '
|
77
|
+
puts self[:output]
|
78
|
+
puts self[:error]
|
79
|
+
puts ' '
|
80
|
+
raise "#{self[:input]} failed" unless self.has_key?(:ignore_failure) && self[:ignore_failure]
|
81
|
+
end
|
69
82
|
end
|
70
83
|
|
71
84
|
def self.machine
|
data/spec/command_spec.rb
CHANGED