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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd6bc730347682ee7cb83f6397e57cdbd97441469bcdd23a45762ead541fa65b
4
- data.tar.gz: ddb67b29b21e989a3f885a25464166c9f641bd72c7bc8546cfe7bf695fdcd7b9
3
+ metadata.gz: 71a03d41938ba2bc030d57d1f9e001d3d46f83883229a403970d3c71944db525
4
+ data.tar.gz: 78821e42067945ed38b4074cacaa35d21d0709c1b81039f2e4c51e8962618be7
5
5
  SHA512:
6
- metadata.gz: 5eac45f42370b2bd9bd373f064330b45d7ad325d0c2cdd278b1901969bd30e0aef3f906ac4602a152736868c13cf2af6b204c3e8a787439c1863f4be40acc9b5
7
- data.tar.gz: d1c3f35a437e74295bbfe7aecd2334439e849ea2cbabec7f78d0a31a2d28760f04ca80f859448b6a2cc82e5a2ad35ce3719e77f994e256a03d5875ef133dbad0
6
+ metadata.gz: 5cd81fe419c51c3cc31cf5fe7eddb143502bcc156ab69dbd299196e2aac9b3c3b5c5d2fc05af169ee4fce94cb5007ab33a4538f01435de1e3a7979ccb2319893
7
+ data.tar.gz: a142379f43421f2b99e3fbe8d524ce2ce7b8fc7f69a81592b43c1b5fe9ce7489b0cf78c43deb44a5afd8dee5779fcea0b33b395f8c4e286224c397ef928123d0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cexpect (0.1.1)
4
+ cexpect (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- def self.spawn(*args)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cexpect
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
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.2
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-04-30 00:00:00.000000000 Z
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: