filter_io 0.2.8 → 0.2.9
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 +5 -5
- data/README.markdown +1 -1
- data/filter_io.gemspec +2 -2
- data/lib/filter_io.rb +3 -3
- data/lib/filter_io/version.rb +1 -1
- data/spec/filter_io_spec.rb +20 -6
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ced2c65cffd42c6978d3baef95fafe4ce41a6442d8d68e8a5743af02bf9ed4bf
|
4
|
+
data.tar.gz: 742d007fdb81e2bfa1bf9276748b66f36284a4147242fa1843a7022be8bd65a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d470cdb65d41eb4c18921df0438b5fe4c43098c7ecb2c581200aa7180cba27269df31da29a99c9d6cce94727410ee05381b0fce263d2ad970b7af9a817ed49fa
|
7
|
+
data.tar.gz: 8cc94e7348e0abfac77832599bec162f95c37e4c10a155c0ecce27b2454400bbc2cc953e5152490bb7ed3b8e659cd221aca4b844a48333016acf8c33fc75fe6e
|
data/README.markdown
CHANGED
@@ -93,7 +93,7 @@ When either `readline`, `gets` or `read(nil)` is called, `filter_io` will proces
|
|
93
93
|
|
94
94
|
Ruby 1.9 has character encoding support can convert between UTF-8, ISO-8859-1, ASCII-8BIT, etc. This is triggered in `IO` by using `:external_encoding` and `:internal_encoding` when opening the stream.
|
95
95
|
`filter_io` will use the underlying stream's encoding settings when reading and filtering data. The processing block will be passed data in the internal encoding.
|
96
|
-
As per the core `IO` object, if `read` is called with a length (in bytes), the data will be returned in
|
96
|
+
As per the core `IO` object, if `read` is called with a length (in bytes), the data will be returned in ASCII-8BIT.
|
97
97
|
In summary, everything should Just Work™
|
98
98
|
|
99
99
|
### Notes on Patches/Pull Requests
|
data/filter_io.gemspec
CHANGED
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.add_development_dependency 'bundler', '~>
|
21
|
-
spec.add_development_dependency 'rake'
|
20
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
21
|
+
spec.add_development_dependency 'rake', '< 2'
|
22
22
|
spec.add_development_dependency 'simplecov'
|
23
23
|
spec.add_development_dependency 'rspec', '~> 2.13'
|
24
24
|
spec.add_development_dependency 'pry'
|
data/lib/filter_io.rb
CHANGED
@@ -188,12 +188,12 @@ class FilterIO
|
|
188
188
|
raise ArgumentError
|
189
189
|
end
|
190
190
|
|
191
|
+
return "" if limit == 0
|
191
192
|
return nil if eof?
|
192
|
-
return read if sep_string.nil?
|
193
193
|
|
194
194
|
paragraph_mode = sep_string == ''
|
195
195
|
sep_string = "\n\n" if paragraph_mode
|
196
|
-
sep_string = sep_string
|
196
|
+
sep_string = sep_string&.to_s unless sep_string.is_a? String
|
197
197
|
|
198
198
|
if paragraph_mode
|
199
199
|
# consume any leading newlines
|
@@ -298,7 +298,7 @@ class FilterIO
|
|
298
298
|
|
299
299
|
def find_bytes(str)
|
300
300
|
with_byte_buffer do
|
301
|
-
@buffer.index(str)
|
301
|
+
str && @buffer.index(str)
|
302
302
|
end
|
303
303
|
end
|
304
304
|
|
data/lib/filter_io/version.rb
CHANGED
data/spec/filter_io_spec.rb
CHANGED
@@ -28,6 +28,8 @@ describe FilterIO do
|
|
28
28
|
errors << [e.class, e.message]
|
29
29
|
end
|
30
30
|
positions << io.pos
|
31
|
+
|
32
|
+
break if results == [""] * 10 && errors == [nil] * 10 && positions == [0] * 10
|
31
33
|
raise 'Too many iterations' if results.size > 100
|
32
34
|
end
|
33
35
|
|
@@ -574,7 +576,7 @@ describe FilterIO do
|
|
574
576
|
end
|
575
577
|
end
|
576
578
|
|
577
|
-
it 'supports `
|
579
|
+
it 'supports `gets` with a limit' do
|
578
580
|
[
|
579
581
|
"",
|
580
582
|
"x",
|
@@ -582,11 +584,24 @@ describe FilterIO do
|
|
582
584
|
"abc\rdef\rghi\r",
|
583
585
|
"über",
|
584
586
|
].each do |input|
|
585
|
-
[1, 2, 3, 4, 10].each do |limit|
|
587
|
+
[0, 1, 2, 3, 4, 10].each do |limit|
|
586
588
|
matches_reference_io_behaviour(input) { |io| io.gets(limit) }
|
587
589
|
end
|
588
590
|
end
|
589
|
-
|
591
|
+
end
|
592
|
+
|
593
|
+
it 'supports `gets` with nil separator and a limit' do
|
594
|
+
[
|
595
|
+
"",
|
596
|
+
"x",
|
597
|
+
"foo\nbar\rbaz\n",
|
598
|
+
"abc\rdef\rghi\r",
|
599
|
+
"über",
|
600
|
+
].each do |input|
|
601
|
+
[0, 1, 2, 3, 4, 10].each do |limit|
|
602
|
+
matches_reference_io_behaviour(input) { |io| io.gets(nil, limit) }
|
603
|
+
end
|
604
|
+
end
|
590
605
|
end
|
591
606
|
|
592
607
|
it 'supports `gets` with a separator and a limit' do
|
@@ -598,15 +613,14 @@ describe FilterIO do
|
|
598
613
|
"über",
|
599
614
|
].each do |input|
|
600
615
|
["\r", "x"].each do |sep_string|
|
601
|
-
[1, 2, 3, 4, 10].each do |limit|
|
616
|
+
[0, 1, 2, 3, 4, 10].each do |limit|
|
602
617
|
matches_reference_io_behaviour(input) { |io| io.gets(sep_string, limit) }
|
603
618
|
end
|
604
619
|
end
|
605
620
|
end
|
606
|
-
# TODO: test zero limit
|
607
621
|
end
|
608
622
|
|
609
|
-
it 'errors when `
|
623
|
+
it 'errors when `gets` is passed more than two args' do
|
610
624
|
expect {
|
611
625
|
FilterIO.new(StringIO.new).gets(1,2,3)
|
612
626
|
}.to raise_error ArgumentError
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Weathered
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
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: '2'
|
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: '2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: simplecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- jason@jasoncodes.com
|
86
86
|
executables: []
|
@@ -101,7 +101,7 @@ homepage: http://github.com/jasoncodes/filter_io
|
|
101
101
|
licenses:
|
102
102
|
- MIT
|
103
103
|
metadata: {}
|
104
|
-
post_install_message:
|
104
|
+
post_install_message:
|
105
105
|
rdoc_options: []
|
106
106
|
require_paths:
|
107
107
|
- lib
|
@@ -116,9 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
|
120
|
-
|
121
|
-
signing_key:
|
119
|
+
rubygems_version: 3.1.6
|
120
|
+
signing_key:
|
122
121
|
specification_version: 4
|
123
122
|
summary: Filter IO streams with a block. Ruby's FilterInputStream.
|
124
123
|
test_files:
|