cexpect 0.1.2 → 0.1.3
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/Gemfile.lock +1 -1
- data/lib/cexpect.rb +2 -10
- data/lib/cexpect/module_methods.rb +36 -0
- data/lib/cexpect/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71a03d41938ba2bc030d57d1f9e001d3d46f83883229a403970d3c71944db525
|
4
|
+
data.tar.gz: 78821e42067945ed38b4074cacaa35d21d0709c1b81039f2e4c51e8962618be7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cd81fe419c51c3cc31cf5fe7eddb143502bcc156ab69dbd299196e2aac9b3c3b5c5d2fc05af169ee4fce94cb5007ab33a4538f01435de1e3a7979ccb2319893
|
7
|
+
data.tar.gz: a142379f43421f2b99e3fbe8d524ce2ce7b8fc7f69a81592b43c1b5fe9ce7489b0cf78c43deb44a5afd8dee5779fcea0b33b395f8c4e286224c397ef928123d0
|
data/Gemfile.lock
CHANGED
data/lib/cexpect.rb
CHANGED
@@ -1,22 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'cexpect/module_methods'
|
3
4
|
require 'delegate'
|
4
5
|
require 'observer'
|
5
|
-
require 'pty'
|
6
6
|
|
7
7
|
#
|
8
8
|
# A module for supplying a different expect method
|
9
9
|
#
|
10
10
|
module CExpect
|
11
|
-
|
12
|
-
original_rd, wr, pid = PTY.spawn(*args)
|
13
|
-
rd = CExpect::Reader.new(original_rd)
|
14
|
-
if block_given?
|
15
|
-
yield(rd, wr, pid)
|
16
|
-
else
|
17
|
-
[rd, wr, pid]
|
18
|
-
end
|
19
|
-
end
|
11
|
+
extend CExpect::ModuleMethods
|
20
12
|
|
21
13
|
#
|
22
14
|
# A class delegating normal operations to a wrapped IO, adding an
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pty'
|
4
|
+
|
5
|
+
module CExpect
|
6
|
+
#
|
7
|
+
# Module methods for CExpect
|
8
|
+
#
|
9
|
+
module ModuleMethods
|
10
|
+
#
|
11
|
+
# Assume first element benefits from using CExpect
|
12
|
+
#
|
13
|
+
# This generalization is a bit iffy; it works for class methods
|
14
|
+
# that returns and yields an IO reader first, followed by any
|
15
|
+
# other parameters. But hey, if we need to wrap things that behave
|
16
|
+
# differently, we can just give this one (and its shared examples
|
17
|
+
# in the specs) a more specific name and implement another.
|
18
|
+
#
|
19
|
+
def cexpect_wrap(array, &block)
|
20
|
+
array[0] = CExpect::Reader.new(array[0])
|
21
|
+
if block_given?
|
22
|
+
block.call(*array)
|
23
|
+
else
|
24
|
+
array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def pipe(*args, &block)
|
29
|
+
cexpect_wrap(IO.pipe(*args), &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def spawn(*args, &block)
|
33
|
+
cexpect_wrap(PTY.spawn(*args), &block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christer Jansson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-03 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:
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- bin/setup
|
32
32
|
- cexpect.gemspec
|
33
33
|
- lib/cexpect.rb
|
34
|
+
- lib/cexpect/module_methods.rb
|
34
35
|
- lib/cexpect/version.rb
|
35
36
|
homepage: https://github.com/kondensatorn/cexpect
|
36
37
|
licenses:
|