filter_io 0.1.5 → 0.1.6

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.5
1
+ 0.1.6
data/lib/filter_io.rb CHANGED
@@ -95,7 +95,7 @@ class FilterIO
95
95
  end
96
96
  data = pop_bytes read_length
97
97
  @pos += bytesize(data)
98
- if length.nil? && data.respond_to?(:encoding)
98
+ if length.nil? && @io.respond_to?(:external_encoding)
99
99
  data.force_encoding @io.external_encoding
100
100
  data.encode! @io.internal_encoding if @io.internal_encoding
101
101
  end
@@ -296,7 +296,7 @@ class FilterIO
296
296
 
297
297
  def process_data(data, initial_data_size)
298
298
 
299
- if data.respond_to? :encoding
299
+ if @io.respond_to? :external_encoding
300
300
  org_encoding = data.encoding
301
301
  data.force_encoding @io.external_encoding
302
302
  additional_data_size = bytesize(data) - initial_data_size
@@ -3,6 +3,7 @@
3
3
  require 'test_helper'
4
4
  require 'stringio'
5
5
  require 'tempfile'
6
+ require 'zlib'
6
7
 
7
8
  class FilterIOTest < ActiveSupport::TestCase
8
9
 
@@ -759,4 +760,18 @@ class FilterIOTest < ActiveSupport::TestCase
759
760
  end
760
761
  end
761
762
 
763
+ test "should be able to read from GzipReader stream" do
764
+ input = "über résumé"
765
+ input.force_encoding 'ASCII-8BIT' if input.respond_to? :force_encoding
766
+ buffer = StringIO.new
767
+ out = Zlib::GzipWriter.new buffer
768
+ out.write input
769
+ out.finish
770
+ buffer.rewind
771
+ io = Zlib::GzipReader.new(buffer)
772
+
773
+ io = FilterIO.new(io)
774
+ assert_equal input, io.read
775
+ end
776
+
762
777
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jason Weathered
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-13 00:00:00 +10:00
17
+ date: 2010-12-02 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency