filter_io 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/lib/filter_io.rb CHANGED
@@ -304,7 +304,7 @@ class FilterIO
304
304
 
305
305
  if data && @block
306
306
  state = BlockState.new @io.pos == data.length, source_eof?
307
- args = [data, state]
307
+ args = [data.dup, state]
308
308
  args = args.first(@block.arity > 0 ? @block.arity : 1)
309
309
  data = @block.call(*args)
310
310
  raise IOError, 'Block returned nil' if data.nil?
@@ -310,6 +310,24 @@ class FilterIOTest < ActiveSupport::TestCase
310
310
  assert_equal expected, io.read
311
311
  end
312
312
 
313
+ test "mutate before NeedMoreData shouldn't affect next block call" do
314
+ input = "foobar"
315
+ expected = [
316
+ ['fo', true],
317
+ ['foob', true],
318
+ ['ar', false],
319
+ ]
320
+ actual = []
321
+ io = FilterIO.new(StringIO.new(input), :block_size => 2) do |data, state|
322
+ actual << [data.dup, state.bof?]
323
+ data.upcase!
324
+ raise FilterIO::NeedMoreData if data == 'FO'
325
+ data
326
+ end
327
+ assert_equal input.upcase, io.read
328
+ assert_equal expected, actual
329
+ end
330
+
313
331
  test "Symbol#to_proc" do
314
332
  input = 'foo bar'
315
333
  expected = 'FOO BAR'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filter_io
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Weathered
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-12 00:00:00 +10:00
18
+ date: 2010-07-13 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency