rubysl-expect 1.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fabee5283790fd0f90819923c61d56b45c409262
4
- data.tar.gz: de080530c48c0328cafa577937ca9a7d336dcead
3
+ metadata.gz: ad480d3cd33d71bc26fecc7f211d3c61f052358a
4
+ data.tar.gz: 6835afcd40436f07d1c29a9eee37c267ba0a6e01
5
5
  SHA512:
6
- metadata.gz: 11cc1a7164df258a365073b4cfb868867219a17171ad61fdfa1c9f529dbf57999f8937ac6fccd7987b67b1621cf16a7749fe7ce29fcb5c5d9613ebf25281b18d
7
- data.tar.gz: b51201079c5b1172e966fec2207a49ae14dcd30f62a4869221ee120b8ef4bdd7706896134779c7122ca53761693238101f1e305341f20e82aaee5140e4a294c2
6
+ metadata.gz: 0310074a683d7a408b247e9bcb9316ce66ac02a8612c861418244e90bae8b3cc5165fc47375eecd22433280a2410e939fd5478965b5d6f977c8ff3a824a42ddf
7
+ data.tar.gz: ad6725795f4e6bcd486ed02667ba73af72c1ac98062e48849c37151703827cab4ca5800257cdefa9497a6b13e7f3279955c8a2b02a24110065277221b961cacc
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system
4
- - gem --version
5
- - gem install rubysl-bundler
6
- script: bundle exec mspec spec
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
7
5
  rvm:
8
- - rbx-nightly-18mode
6
+ - 1.9.3
7
+ - rbx-nightly-19mode
@@ -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 !IO.select([self],nil,nil,timeout) or eof? then
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
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module Expect
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -19,5 +19,4 @@ Gem::Specification.new do |spec|
19
19
  spec.add_development_dependency "bundler", "~> 1.3"
20
20
  spec.add_development_dependency "rake", "~> 10.0"
21
21
  spec.add_development_dependency "mspec", "~> 1.5"
22
- spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
23
22
  end
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: 1.0.0
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-12-27 00:00:00.000000000 Z
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