fastercsv 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -4,6 +4,11 @@ Below is a complete listing of changes for each revision of FasterCSV.
4
4
 
5
5
  == 1.2.1
6
6
 
7
+ * Worked around GzipReader's lack of a seek() method so we could still use
8
+ automatic row separator detection with them.
9
+
10
+ == 1.2.1
11
+
7
12
  * Worked around an odd incompatibility with the Regexps used to remove line
8
13
  endings in some (seemingly rare) Ruby environments.
9
14
  * Made FasterCSV::lineno() writer aware.
data/lib/faster_csv.rb CHANGED
@@ -75,7 +75,7 @@ require "stringio"
75
75
  #
76
76
  class FasterCSV
77
77
  # The version of the installed library.
78
- VERSION = "1.2.1".freeze
78
+ VERSION = "1.2.2".freeze
79
79
 
80
80
  #
81
81
  # A FasterCSV::Row is part Array and part Hash. It retains an order for the
@@ -1646,7 +1646,14 @@ class FasterCSV
1646
1646
  break
1647
1647
  end
1648
1648
  end
1649
- @io.seek(saved_pos) # reset back to the remembered position
1649
+ # tricky seek() clone to work around GzipReader's lack of seek()
1650
+ @io.rewind
1651
+ # reset back to the remembered position
1652
+ while saved_pos > 1024 # avoid loading a lot of data into memory
1653
+ @io.read(1024)
1654
+ saved_pos -= 1024
1655
+ end
1656
+ @io.read(saved_pos) if saved_pos.nonzero?
1650
1657
  rescue IOError # stream not opened for reading
1651
1658
  @row_sep = $INPUT_RECORD_SEPARATOR
1652
1659
  end
data/test/tc_features.rb CHANGED
@@ -6,6 +6,7 @@
6
6
  # Copyright 2005 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
+ require "zlib"
9
10
 
10
11
  require "faster_csv"
11
12
 
@@ -145,6 +146,18 @@ class TestFasterCSVFeatures < Test::Unit::TestCase
145
146
  assert_equal([[nil, nil, "A", "B", "C"], ["1", "2", "3"]], parsed)
146
147
  end
147
148
 
149
+ def test_gzip_reader_bug_fix
150
+ zipped = nil
151
+ assert_nothing_raised(NoMethodError) do
152
+ zipped = FasterCSV.new(
153
+ Zlib::GzipReader.open(
154
+ File.join(File.dirname(__FILE__), "line_endings.gz")
155
+ )
156
+ )
157
+ end
158
+ assert_equal("\r\n", zipped.instance_eval { @row_sep })
159
+ end
160
+
148
161
  def test_version
149
162
  assert_not_nil(FasterCSV::VERSION)
150
163
  assert_instance_of(String, FasterCSV::VERSION)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: fastercsv
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.1
7
- date: 2007-09-20 00:00:00 -05:00
6
+ version: 1.2.2
7
+ date: 2007-12-01 00:00:00 -06:00
8
8
  summary: FasterCSV is CSV, but faster, smaller, and cleaner.
9
9
  require_paths:
10
10
  - lib