filter_io 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/filter_io.gemspec +2 -2
- data/lib/filter_io/version.rb +1 -1
- data/lib/filter_io.rb +4 -4
- data/spec/filter_io_spec.rb +3 -3
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bb6c9bf480676e8e8f76bc297c78b2898cca42d2a4b366d62b117c5edf73167
|
4
|
+
data.tar.gz: c9994613dd2f4baad9eb51a8403e821ffae1faa3f1bcaa0edb3c1969349efccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 027622b16c8febb4e1cc978f603bbb9c4d1527c13bed972a0633ef61015593d728728d61c18a87c80c141849796c50acbfde8d7cd775de773eb6cd441389b5ad
|
7
|
+
data.tar.gz: 6dc6d5c4d8ecb4ebf980bde869091ed0afeee5380e4e61dfbef1dab9add5bafbf1ea99327038d5460a3b1e7f53ca81f01f2e103694fbe335f1def9098d00d79e
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.5
|
data/filter_io.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
21
|
-
spec.add_development_dependency 'rake'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
22
|
spec.add_development_dependency 'simplecov'
|
23
|
-
spec.add_development_dependency 'rspec', '~>
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
24
|
spec.add_development_dependency 'pry'
|
25
25
|
end
|
data/lib/filter_io/version.rb
CHANGED
data/lib/filter_io.rb
CHANGED
@@ -54,12 +54,11 @@ class FilterIO
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def default_encoding
|
57
|
-
|
57
|
+
@default_encoding ||= begin
|
58
58
|
c = @io.getc
|
59
59
|
@io.ungetc c
|
60
|
-
|
60
|
+
c.encoding
|
61
61
|
end
|
62
|
-
@default_encoding
|
63
62
|
end
|
64
63
|
|
65
64
|
def internal_encoding
|
@@ -103,6 +102,7 @@ class FilterIO
|
|
103
102
|
return '' if length == 0
|
104
103
|
|
105
104
|
# fill the buffer up to the fill level (or whole input if length is nil)
|
105
|
+
@did_first_read ||= false
|
106
106
|
while (!source_eof? || !@did_first_read) && (length.nil? || length > @buffer.bytesize)
|
107
107
|
@did_first_read = true
|
108
108
|
buffer_data @options[:block_size] || length
|
@@ -325,7 +325,7 @@ class FilterIO
|
|
325
325
|
# and add some more data to the buffer
|
326
326
|
raise NeedMoreData
|
327
327
|
end
|
328
|
-
rescue NeedMoreData
|
328
|
+
rescue NeedMoreData
|
329
329
|
raise EOFError, 'end of file reached' if @io.eof?
|
330
330
|
new_data = @io.read(block_size).force_encoding(external_encoding)
|
331
331
|
data << new_data
|
data/spec/filter_io_spec.rb
CHANGED
@@ -206,7 +206,7 @@ describe FilterIO do
|
|
206
206
|
|
207
207
|
it 'converts ISO-8859-1 to UTF-8 via a block' do
|
208
208
|
[1, 2, nil].each do |block_size|
|
209
|
-
expected
|
209
|
+
# expected: "über\nrésumé"
|
210
210
|
with_iso8859_1_test_file 'UTF-8' do |io_raw|
|
211
211
|
io = FilterIO.new(io_raw, :block_size => block_size) do |data, state|
|
212
212
|
if state.bof?
|
@@ -227,7 +227,7 @@ describe FilterIO do
|
|
227
227
|
|
228
228
|
it 'converts ISO-8859-1 to raw via a block' do
|
229
229
|
[1, 2, nil].each do |block_size|
|
230
|
-
expected
|
230
|
+
# expected: "über\nrésumé".encode('ISO-8859-1')
|
231
231
|
with_iso8859_1_test_file 'ISO-8859-1' do |io_raw|
|
232
232
|
io = FilterIO.new(io_raw, :block_size => block_size) do |data, state|
|
233
233
|
if state.bof?
|
@@ -465,7 +465,7 @@ describe FilterIO do
|
|
465
465
|
|
466
466
|
it 'can be rewound with block' do
|
467
467
|
input = 'abcdefghij'
|
468
|
-
expected
|
468
|
+
# expected: input[1..-1]
|
469
469
|
io = FilterIO.new(StringIO.new(input), :block_size => 4) do |data, state|
|
470
470
|
data = data[1..-1] if state.bof?
|
471
471
|
data
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filter_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Weathered
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: simplecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
+
- ".tool-versions"
|
91
92
|
- Gemfile
|
92
93
|
- LICENSE
|
93
94
|
- README.markdown
|
@@ -116,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
117
|
- !ruby/object:Gem::Version
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
120
|
+
rubygems_version: 3.2.32
|
120
121
|
signing_key:
|
121
122
|
specification_version: 4
|
122
123
|
summary: Filter IO streams with a block. Ruby's FilterInputStream.
|