threaded_runner 1.0.0
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 +7 -0
- data/lib/threaded_runner.rb +36 -0
- data/long_talkative_process.sh +11 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5acfd9fec8fcca6aaf8b75462f7d141028d31c1e
|
4
|
+
data.tar.gz: 47ed3909f322800ac4573d3093deb06ee8c1f88e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c306932afe243916f3b0d530e91c709cdaf594c292edf252b000f053ee4c5ef7a8b8209d6ab9cf51d57dfc83f8197b72cc4e3de8b020e4fb71170c3b77544071
|
7
|
+
data.tar.gz: ef7ba20e72b15208e16df89e606a6577ea1a865a14031dc8835c0f9467be64cc1524b5dad4f8aa768c8844a7b54e0d35b979d8120d03e6d1b31df1500a151a11
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class ThreadedRunner
|
2
|
+
def initialize(cmd)
|
3
|
+
@cmd = cmd
|
4
|
+
end
|
5
|
+
|
6
|
+
attr_reader :thread
|
7
|
+
|
8
|
+
def start(wait_for=nil)
|
9
|
+
@thread = Thread.new do
|
10
|
+
IO.popen(@cmd) do |f|
|
11
|
+
@pid = f.pid
|
12
|
+
f.each_line do |line|
|
13
|
+
line.strip!
|
14
|
+
yield line if block_given?
|
15
|
+
if @regex && line =~ @regex
|
16
|
+
@gotit = true
|
17
|
+
@regex = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
nil
|
23
|
+
wait_for(wait_for) if wait_for
|
24
|
+
end
|
25
|
+
|
26
|
+
def wait_for(output)
|
27
|
+
@regex = output
|
28
|
+
sleep 0.2 until @gotit
|
29
|
+
@gotit = false
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def stop
|
34
|
+
Process.kill("TERM", @pid)
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: threaded_runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Fairbairn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |2
|
14
|
+
This class allows you to wait for your subprocess to output a line matching a
|
15
|
+
given regex, and also yields each line of the subprocess' output to an optional
|
16
|
+
block.
|
17
|
+
email: james@netlagoon.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/threaded_runner.rb
|
23
|
+
- long_talkative_process.sh
|
24
|
+
homepage: https://github.com/jfairbairn/threaded_runner
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.5.1
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: A simple class to run subprocesses under test in a thread
|
48
|
+
test_files: []
|