filter_io 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2daf76da95ab847d8218f60d72f21bf35c5c9456
4
+ data.tar.gz: 045a05eb40a210da7c266a4467e0c85577c08055
5
+ SHA512:
6
+ metadata.gz: 4203fb5d9ba5cde5c0cba11a105c62cb5b944069cb8ffe39b3691533d862477d47f8c6d52c766681d9ec25888311e8af0f1762f2eb76074e5ef6cdf064f2036c
7
+ data.tar.gz: 8c25baecac50a4b62d2c14147384dfd0cf875e2f7ce2336bd979bdb534d6d5c32fb661ee4fead5f2369ade08bcbb78235d45e7092ff83ed67e2b2a12e9d6c4fc
@@ -1,3 +1,3 @@
1
1
  class FilterIO
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
data/lib/filter_io.rb CHANGED
@@ -215,8 +215,7 @@ class FilterIO
215
215
 
216
216
  def each_line(sep_string = $/)
217
217
  unless block_given?
218
- klass = defined?(Enumerator) ? Enumerator : Enumerable::Enumerator
219
- return klass.new(self, :each_line, sep_string)
218
+ return to_enum(:each_line, sep_string)
220
219
  end
221
220
  while line = gets(sep_string)
222
221
  yield line
@@ -264,10 +263,12 @@ class FilterIO
264
263
  def buffer_data(block_size = nil)
265
264
  block_size ||= DEFAULT_BLOCK_SIZE
266
265
 
267
- data = unless @buffer_raw.empty?
268
- @buffer_raw.slice! 0, @buffer_raw.bytesize
266
+ if !@buffer_raw.empty?
267
+ data = @buffer_raw.slice! 0, @buffer_raw.bytesize
268
+ elsif data = @io.read(block_size)
269
+ data.force_encoding(external_encoding)
269
270
  else
270
- @io.read(block_size) or return
271
+ return
271
272
  end
272
273
 
273
274
  initial_data_size = data.bytesize
@@ -283,7 +284,7 @@ class FilterIO
283
284
  end
284
285
  rescue NeedMoreData => e
285
286
  raise EOFError, 'end of file reached' if @io.eof?
286
- data << @io.read(block_size)
287
+ data << @io.read(block_size).force_encoding(external_encoding)
287
288
  retry
288
289
  end
289
290
 
@@ -240,6 +240,16 @@ describe FilterIO do
240
240
  end
241
241
  end
242
242
 
243
+ it 'supports reading multibyte characters overlapping block boundaries' do
244
+ input = "\x49\xE2\x99\xA5\x4E\x59\x49\xE2\x99\xA5\x4E\x59".force_encoding('UTF-8')
245
+
246
+ io = FilterIO.new(StringIO.new(input), :block_size => 6) do |data, state|
247
+ [data.byteslice(0).force_encoding('UTF-8'), data.byteslice(1..-1).force_encoding('UTF-8')]
248
+ end
249
+
250
+ expect(io.read).to eq input
251
+ end
252
+
243
253
  it 'supports a block returning mix of UTF-8 and ASCII-8BIT' do
244
254
  input = "X\xE2\x80\x94Y\xe2\x80\x99"
245
255
  input.force_encoding 'ASCII-8BIT'
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filter_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jason Weathered
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-07 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.3.9
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.3.9
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '1.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '1.3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: simplecov
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: '2.13'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: '2.13'
94
83
  description:
@@ -98,12 +87,11 @@ executables: []
98
87
  extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
101
- - .gitignore
90
+ - ".gitignore"
102
91
  - Gemfile
103
92
  - LICENSE
104
93
  - README.markdown
105
94
  - Rakefile
106
- - VERSION
107
95
  - filter_io.gemspec
108
96
  - lib/filter_io.rb
109
97
  - lib/filter_io/version.rb
@@ -112,33 +100,26 @@ files:
112
100
  homepage: http://github.com/jasoncodes/filter_io
113
101
  licenses:
114
102
  - MIT
103
+ metadata: {}
115
104
  post_install_message:
116
105
  rdoc_options: []
117
106
  require_paths:
118
107
  - lib
119
108
  required_ruby_version: !ruby/object:Gem::Requirement
120
- none: false
121
109
  requirements:
122
- - - ! '>='
110
+ - - ">="
123
111
  - !ruby/object:Gem::Version
124
112
  version: '0'
125
- segments:
126
- - 0
127
- hash: 4419547183379968853
128
113
  required_rubygems_version: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
- segments:
135
- - 0
136
- hash: 4419547183379968853
137
118
  requirements: []
138
119
  rubyforge_project:
139
- rubygems_version: 1.8.24
120
+ rubygems_version: 2.2.0
140
121
  signing_key:
141
- specification_version: 3
122
+ specification_version: 4
142
123
  summary: Filter IO streams with a block. Ruby's FilterInputStream.
143
124
  test_files:
144
125
  - spec/filter_io_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.6