rubysl-expect 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/lib/rubysl/expect/expect.rb +17 -2
- data/lib/rubysl/expect/version.rb +1 -1
- data/rubysl-expect.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad480d3cd33d71bc26fecc7f211d3c61f052358a
|
4
|
+
data.tar.gz: 6835afcd40436f07d1c29a9eee37c267ba0a6e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0310074a683d7a408b247e9bcb9316ce66ac02a8612c861418244e90bae8b3cc5165fc47375eecd22433280a2410e939fd5478965b5d6f977c8ff3a824a42ddf
|
7
|
+
data.tar.gz: ad6725795f4e6bcd486ed02667ba73af72c1ac98062e48849c37151703827cab4ca5800257cdefa9497a6b13e7f3279955c8a2b02a24110065277221b961cacc
|
data/.travis.yml
CHANGED
data/lib/rubysl/expect/expect.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
$expect_verbose = false
|
2
2
|
|
3
3
|
class IO
|
4
|
+
# Reads from the IO until pattern +pat+ matches or the +timeout+ is over.
|
5
|
+
# It returns an array with the read buffer, followed by the matches.
|
6
|
+
# If a block is given, the result is yielded to the block and returns nil.
|
7
|
+
#
|
8
|
+
# The optional timeout parameter defines, in seconds, the total time to wait
|
9
|
+
# for the pattern. If the timeout expires or eof is found, nil is returned
|
10
|
+
# or yielded. However, the buffer in a timeout session is kept for the next
|
11
|
+
# expect call. The default timeout is 9999999 seconds.
|
4
12
|
def expect(pat,timeout=9999999)
|
5
13
|
buf = ''
|
6
14
|
case pat
|
@@ -8,13 +16,20 @@ class IO
|
|
8
16
|
e_pat = Regexp.new(Regexp.quote(pat))
|
9
17
|
when Regexp
|
10
18
|
e_pat = pat
|
19
|
+
else
|
20
|
+
raise TypeError, "unsupported pattern class: #{pattern.class}"
|
11
21
|
end
|
22
|
+
@unusedBuf ||= ''
|
12
23
|
while true
|
13
|
-
if
|
24
|
+
if not @unusedBuf.empty?
|
25
|
+
c = @unusedBuf.slice!(0).chr
|
26
|
+
elsif !IO.select([self],nil,nil,timeout) or eof? then
|
14
27
|
result = nil
|
28
|
+
@unusedBuf = buf
|
15
29
|
break
|
30
|
+
else
|
31
|
+
c = getc.chr
|
16
32
|
end
|
17
|
-
c = getc.chr
|
18
33
|
buf << c
|
19
34
|
if $expect_verbose
|
20
35
|
STDOUT.print c
|
data/rubysl-expect.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-expect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubysl-prettyprint
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
55
|
description: Ruby standard library expect.
|
70
56
|
email:
|
71
57
|
- brixen@gmail.com
|