io-stream 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/io/stream/generic.rb +12 -7
- data/lib/io/stream/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d85df6aecb7833dd6945292040cb635510f088df8dc0f9427b207ada1b8fcfa
|
4
|
+
data.tar.gz: 07b3d70a28adc36c23286f42f92c0d9eec99a3a176efbbb839c3f4c9d34a13fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40a994276d5cab512b1c77213ba48c02fe7916256c0070893f37bc641baea4ecf277ee3695b76357617b6e5366ddb22fbf8ff5839f7c64698edc01b3bc2ced9
|
7
|
+
data.tar.gz: 21ae83634d2c036a2c60865fdafb26de516fc8a0822c45ff018fd6c887079c73dcb63ace72f07b316d87b5973b4de5d3d673d435a89f09c755361ab0a63238ce
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/io/stream/generic.rb
CHANGED
@@ -86,9 +86,11 @@ module IO::Stream
|
|
86
86
|
end
|
87
87
|
|
88
88
|
# Efficiently read data from the stream until encountering pattern.
|
89
|
-
# @
|
90
|
-
# @
|
91
|
-
|
89
|
+
# @parameter pattern [String] The pattern to match.
|
90
|
+
# @parameter offset [Integer] The offset to start searching from.
|
91
|
+
# @parameter limit [Integer] The maximum number of bytes to read, including the pattern (even if chomped).
|
92
|
+
# @returns [String | Nil] The contents of the stream up until the pattern, which is consumed but not returned.
|
93
|
+
def read_until(pattern, offset = 0, limit: nil, chomp: true)
|
92
94
|
# We don't want to split on the pattern, so we subtract the size of the pattern.
|
93
95
|
split_offset = pattern.bytesize - 1
|
94
96
|
|
@@ -97,9 +99,12 @@ module IO::Stream
|
|
97
99
|
|
98
100
|
offset = 0 if offset < 0
|
99
101
|
|
100
|
-
return
|
102
|
+
return nil if limit and offset >= limit
|
103
|
+
return nil unless fill_read_buffer
|
101
104
|
end
|
102
105
|
|
106
|
+
return nil if limit and index >= limit
|
107
|
+
|
103
108
|
@read_buffer.freeze
|
104
109
|
matched = @read_buffer.byteslice(0, index+(chomp ? 0 : pattern.bytesize))
|
105
110
|
@read_buffer = @read_buffer.byteslice(index+pattern.bytesize, @read_buffer.bytesize)
|
@@ -148,8 +153,8 @@ module IO::Stream
|
|
148
153
|
|
149
154
|
# Writes `string` to the buffer. When the buffer is full or #sync is true the
|
150
155
|
# buffer is flushed to the underlying `io`.
|
151
|
-
# @
|
152
|
-
# @
|
156
|
+
# @parameter string [String] the string to write to the buffer.
|
157
|
+
# @returns [Integer] the number of bytes appended to the buffer.
|
153
158
|
def write(string, flush: false)
|
154
159
|
@writing.synchronize do
|
155
160
|
@write_buffer << string
|
@@ -292,7 +297,7 @@ module IO::Stream
|
|
292
297
|
end
|
293
298
|
|
294
299
|
# Consumes at most `size` bytes from the buffer.
|
295
|
-
# @
|
300
|
+
# @parameter size [Integer|nil] The amount of data to consume. If nil, consume entire buffer.
|
296
301
|
def consume_read_buffer(size = nil)
|
297
302
|
# If we are at eof, and the read buffer is empty, we can't consume anything.
|
298
303
|
return nil if @eof && @read_buffer.empty?
|
data/lib/io/stream/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -37,7 +37,7 @@ cert_chain:
|
|
37
37
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
38
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
39
|
-----END CERTIFICATE-----
|
40
|
-
date: 2024-10-
|
40
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
41
41
|
dependencies: []
|
42
42
|
description:
|
43
43
|
email:
|
metadata.gz.sig
CHANGED
Binary file
|