cexpect 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +2 -2
- data/Gemfile.lock +20 -20
- data/README.md +3 -0
- data/lib/cexpect.rb +19 -19
- data/lib/cexpect/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d6f51d1822901ccaef277fd26017749f6d65ed3eaea50836fa2fbe5b7e90410
|
4
|
+
data.tar.gz: 9eade35e51126e2ce00f99a02f3f1052f09314ecd19b516cb51f0d7ea4438139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a4cc9e4edfa0b18fa6d57f0c43f0fefae54b8872de8fe09c56595b31bf203a0aa5a24fe8005ebc737483c5a7d5e293fdd1d95276a57faccb717e786420ddc1
|
7
|
+
data.tar.gz: 180e097fe5134c7527264a9a464bb5d4c27a8317dd08aef3886a560e997a00f1836f6740987fe6ccf83e8f181be8e5509f6a0ad2849b5788f89d9ac60312c1d6
|
data/.github/workflows/ruby.yml
CHANGED
@@ -24,9 +24,9 @@ jobs:
|
|
24
24
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
25
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
26
|
# uses: ruby/setup-ruby@v1
|
27
|
-
uses: ruby/setup-ruby@
|
27
|
+
uses: ruby/setup-ruby@v1.70.1
|
28
28
|
with:
|
29
|
-
ruby-version:
|
29
|
+
ruby-version: 3.0
|
30
30
|
- name: Install dependencies
|
31
31
|
run: bundle install
|
32
32
|
- name: Run tests
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cexpect (0.1.
|
4
|
+
cexpect (0.1.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
diff-lcs (1.
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.4.4)
|
11
11
|
jaro_winkler (1.5.4)
|
12
|
-
parallel (1.
|
13
|
-
parser (
|
14
|
-
ast (~> 2.4.
|
12
|
+
parallel (1.20.1)
|
13
|
+
parser (3.0.1.1)
|
14
|
+
ast (~> 2.4.1)
|
15
15
|
rainbow (3.0.0)
|
16
16
|
rake (12.3.3)
|
17
|
-
rexml (3.2.
|
18
|
-
rspec (3.
|
19
|
-
rspec-core (~> 3.
|
20
|
-
rspec-expectations (~> 3.
|
21
|
-
rspec-mocks (~> 3.
|
22
|
-
rspec-core (3.
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-expectations (3.
|
17
|
+
rexml (3.2.5)
|
18
|
+
rspec (3.10.0)
|
19
|
+
rspec-core (~> 3.10.0)
|
20
|
+
rspec-expectations (~> 3.10.0)
|
21
|
+
rspec-mocks (~> 3.10.0)
|
22
|
+
rspec-core (3.10.1)
|
23
|
+
rspec-support (~> 3.10.0)
|
24
|
+
rspec-expectations (3.10.1)
|
25
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-mocks (3.
|
26
|
+
rspec-support (~> 3.10.0)
|
27
|
+
rspec-mocks (3.10.2)
|
28
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-support (3.
|
29
|
+
rspec-support (~> 3.10.0)
|
30
|
+
rspec-support (3.10.2)
|
31
31
|
rubocop (0.82.0)
|
32
32
|
jaro_winkler (~> 1.5.1)
|
33
33
|
parallel (~> 1.10)
|
@@ -36,9 +36,9 @@ GEM
|
|
36
36
|
rexml
|
37
37
|
ruby-progressbar (~> 1.7)
|
38
38
|
unicode-display_width (>= 1.4.0, < 2.0)
|
39
|
-
rubocop-rspec (1.
|
39
|
+
rubocop-rspec (1.41.0)
|
40
40
|
rubocop (>= 0.68.1)
|
41
|
-
ruby-progressbar (1.
|
41
|
+
ruby-progressbar (1.11.0)
|
42
42
|
unicode-display_width (1.7.0)
|
43
43
|
|
44
44
|
PLATFORMS
|
data/README.md
CHANGED
data/lib/cexpect.rb
CHANGED
@@ -15,11 +15,9 @@ module CExpect
|
|
15
15
|
# expect method
|
16
16
|
#
|
17
17
|
class Reader < SimpleDelegator
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@leftovers = ''
|
22
|
-
super
|
18
|
+
def initialize(io, observers = nil)
|
19
|
+
extend(LoggingReader) if observers
|
20
|
+
super(io)
|
23
21
|
end
|
24
22
|
|
25
23
|
def expect(pat, timeout = nil, match_method: :re_match)
|
@@ -45,22 +43,17 @@ module CExpect
|
|
45
43
|
def expect_try(pat, buf, timeout, match_method)
|
46
44
|
c = getc(timeout)
|
47
45
|
|
48
|
-
if c.nil?
|
49
|
-
@leftovers = buf
|
50
|
-
throw(:result, nil)
|
51
|
-
end
|
46
|
+
throw(:result, nil) if c.nil?
|
52
47
|
|
53
48
|
buf << c
|
54
49
|
|
55
|
-
log(pat, buf)
|
50
|
+
log(pat, buf) if respond_to?(:log)
|
56
51
|
|
57
52
|
result = send(match_method, buf, pat)
|
58
53
|
throw(:result, result) if result
|
59
54
|
end
|
60
55
|
|
61
56
|
def getc(timeout)
|
62
|
-
return @leftovers.slice!(0).chr unless @leftovers.empty?
|
63
|
-
|
64
57
|
rd = __getobj__
|
65
58
|
|
66
59
|
return nil if !IO.select([rd], nil, nil, timeout) || eof?
|
@@ -68,13 +61,6 @@ module CExpect
|
|
68
61
|
rd.getc.chr
|
69
62
|
end
|
70
63
|
|
71
|
-
def log(pat, buf)
|
72
|
-
return if count_observers.zero?
|
73
|
-
|
74
|
-
changed
|
75
|
-
notify_observers(pat, buf)
|
76
|
-
end
|
77
|
-
|
78
64
|
def re_match(buf, pat)
|
79
65
|
buf.match(pat)
|
80
66
|
end
|
@@ -83,4 +69,18 @@ module CExpect
|
|
83
69
|
buf[0, buf.size - pat.size] if buf.end_with?(pat)
|
84
70
|
end
|
85
71
|
end
|
72
|
+
|
73
|
+
#
|
74
|
+
# Adds logging capability when observers are given to constructor
|
75
|
+
#
|
76
|
+
module LoggingReader
|
77
|
+
include Observable
|
78
|
+
|
79
|
+
def log(pat, buf)
|
80
|
+
return if count_observers.zero?
|
81
|
+
|
82
|
+
changed
|
83
|
+
notify_observers(pat, buf)
|
84
|
+
end
|
85
|
+
end
|
86
86
|
end
|
data/lib/cexpect/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cexpect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christer Jansson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An expect method with more reasonable return values and logging functionality
|
14
14
|
email:
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.1.
|
59
|
+
rubygems_version: 3.1.6
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: An improved expect method
|