spud 0.1.14 → 0.1.15
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/shell.rb +20 -11
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff2253281ad17fa26000da387d071fca88fe39e6c01913573bf1aa78148c9302
|
4
|
+
data.tar.gz: 449e2aead6ea9686659c8b928ca9f4fa07f582156d30e2ae24bbc5680382cd58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f29e51971b0f78eb223e0561bc28a641fa167d72a5e10f996752fffefe8ead8c8fbb09707a24b2192c72b341dd039711808cfe2d6b7dbe78e5cb416c71075a8
|
7
|
+
data.tar.gz: 244352f4d935f8f00bc307b88f810743358e1eed079c9f7ef8ffabaca55df1929e9eb7933c5ae76a29bdfa4f9037a519b1ee205e592e49ed3e49f1207a1d4f51
|
data/lib/shell.rb
CHANGED
@@ -1,25 +1,34 @@
|
|
1
|
+
require 'stringio'
|
1
2
|
require 'open3'
|
2
3
|
|
3
4
|
module Spud
|
4
5
|
class Shell < String
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(cmd, silent: false)
|
6
|
+
def initialize(cmd, silent: false, wait: false)
|
8
7
|
output = StringIO.new
|
9
8
|
|
10
|
-
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
stdin, out, @status = Open3.popen2e(cmd)
|
10
|
+
@thread = Thread.new do
|
11
|
+
while line = out.gets
|
12
|
+
puts line unless silent
|
13
|
+
output.puts line
|
14
|
+
super(output.string)
|
15
|
+
end
|
16
|
+
|
17
|
+
out.close
|
18
|
+
stdin.close
|
15
19
|
end
|
16
20
|
|
17
|
-
|
21
|
+
@thread.join if wait
|
22
|
+
end
|
23
|
+
|
24
|
+
def status
|
25
|
+
@status.value
|
18
26
|
end
|
19
27
|
|
20
28
|
def kill!
|
21
|
-
|
22
|
-
thread.
|
29
|
+
Process.kill('KILL', @status.pid)
|
30
|
+
@thread.kill
|
31
|
+
@thread.join
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
data/lib/version.rb
CHANGED