threaded_runner 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/threaded_runner.rb +12 -9
- 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: 2fd48996c0b12b1baabfc4dc59eef840357cdd74
|
4
|
+
data.tar.gz: 4f5f54e75b6038c1ff26eadc560c68a88690f9fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d657db304a24771962510eb0cda3e3a987b248d86a7db6aac917c454a310935f4fc09d4b959d83257de0dff6ff928385753be3bbbb8b3fe4773bc55cae44e6b5
|
7
|
+
data.tar.gz: bd656b22e7a602033ea344309274199463067554fcbbf6e58f9906764aea5d93803642b1a465104d7a0b554117f8420d00584acf0f6ada2da40411bc954f5425
|
data/lib/threaded_runner.rb
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
class ThreadedRunner
|
2
|
-
def initialize(cmd)
|
2
|
+
def initialize(cmd, wdir='.')
|
3
3
|
@cmd = cmd
|
4
|
+
@wdir = wdir
|
4
5
|
end
|
5
6
|
|
6
7
|
attr_reader :thread
|
7
8
|
|
8
9
|
def start(wait_for=nil)
|
9
10
|
@thread = Thread.new do
|
10
|
-
|
11
|
-
@
|
12
|
-
|
13
|
-
line
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
|
11
|
+
Dir.chdir(@wdir) do
|
12
|
+
IO.popen(@cmd) do |f|
|
13
|
+
@pid = f.pid
|
14
|
+
f.each_line do |line|
|
15
|
+
line.strip!
|
16
|
+
yield line if block_given?
|
17
|
+
if @regex && line =~ @regex
|
18
|
+
@gotit = true
|
19
|
+
@regex = nil
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|