fastercsv 1.5.4 → 1.5.5

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.
data/CHANGELOG CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Below is a complete listing of changes for each revision of FasterCSV.
4
4
 
5
+ == 1.5.5
6
+
7
+ * Removed setup.rb due to licensing concerns.
8
+ * Updated and clarified Copyright notices.
9
+ * Improved stray quoting error message (patch by Edvard Majakari).
10
+ * Improved line ending detection algorithm (patch by Alexey Smolianinov).
11
+
5
12
  == 1.5.4
6
13
 
7
14
  * Improved test coverage for the parser.
data/INSTALL CHANGED
@@ -20,14 +20,6 @@ command:
20
20
 
21
21
  $ rake package
22
22
 
23
- == Installing Manually
24
-
25
- Download the latest version of FasterCSV from the
26
- {RubyForge project page}[http://rubyforge.org/frs/?group_id=1102]. Navigate to
27
- the root project directory and enter:
28
-
29
- $ sudo ruby setup.rb
30
-
31
23
  == Running the Tests
32
24
 
33
25
  If you would like to run FasterCSV's test suite on your system before installing
data/LICENSE CHANGED
@@ -1,5 +1,7 @@
1
1
  = License Terms
2
2
 
3
+ This project is copyright Gray Productions Software Inc. and Ubiquitous Business Technology, Inc. with all rights reserved.
4
+
3
5
  Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the
4
6
  {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt] by
5
7
  James Edward Gray II.
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ Rake::RDocTask.new do |rdoc|
20
20
  rdoc.main = "README"
21
21
  rdoc.rdoc_dir = "doc/html"
22
22
  rdoc.title = "FasterCSV Documentation"
23
+ rdoc.options = %w[--charset utf-8]
23
24
  rdoc.rdoc_files.include( "README", "INSTALL",
24
25
  "TODO", "CHANGELOG",
25
26
  "AUTHORS", "COPYING",
@@ -61,7 +62,7 @@ spec = Gem::Specification.new do |spec|
61
62
  reject { |item| item.include?(".svn") } +
62
63
  Dir.glob("{test,examples}/**/*.csv").
63
64
  reject { |item| item.include?(".svn") } +
64
- %w[Rakefile setup.rb test/line_endings.gz]
65
+ %w[Rakefile test/line_endings.gz]
65
66
 
66
67
  spec.has_rdoc = true
67
68
  spec.extra_rdoc_files = %w[ AUTHORS COPYING README INSTALL TODO CHANGELOG
@@ -3,7 +3,7 @@
3
3
  # shortcut_interface.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2006-04-01.
6
- # Copyright 2006 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
  #
8
8
  # Feature implementation and example code by Ara.T.Howard.
9
9
 
@@ -100,7 +100,7 @@ else
100
100
  #
101
101
  class FasterCSV
102
102
  # The version of the installed library.
103
- VERSION = "1.5.4".freeze
103
+ VERSION = "1.5.5".freeze
104
104
 
105
105
  #
106
106
  # A FasterCSV::Row is part Array and part Hash. It retains an order for the
@@ -1258,7 +1258,7 @@ else
1258
1258
  # a into an Array. Note that if +line+ contains multiple rows, anything
1259
1259
  # beyond the first row is ignored.
1260
1260
  #
1261
- # The +options+ parameter can be anthing FasterCSV::new() understands.
1261
+ # The +options+ parameter can be anything FasterCSV::new() understands.
1262
1262
  #
1263
1263
  def self.parse_line(line, options = Hash.new)
1264
1264
  new(line, options).shift
@@ -1297,7 +1297,7 @@ else
1297
1297
  # list.) If you pass a String for +data+, you can later retrieve it (after
1298
1298
  # writing to it, for example) with FasterCSV.string().
1299
1299
  #
1300
- # Note that a wrapped String will be positioned at at the beginning (for
1300
+ # Note that a wrapped String will be positioned at the beginning (for
1301
1301
  # reading). If you want it at the end (for writing), use
1302
1302
  # FasterCSV::generate(). If you want any other positioning, pass a preset
1303
1303
  # StringIO object instead.
@@ -1318,9 +1318,7 @@ else
1318
1318
  # even if it occurs in a quoted field,
1319
1319
  # assuming that you would have the same
1320
1320
  # line endings there. If none of those
1321
- # sequences is found, +data+ is
1322
- # <tt>ARGF</tt>, <tt>STDIN</tt>,
1323
- # <tt>STDOUT</tt>, or <tt>STDERR</tt>,
1321
+ # sequences is found,
1324
1322
  # or the stream is only available for
1325
1323
  # output, the default
1326
1324
  # <tt>$INPUT_RECORD_SEPARATOR</tt>
@@ -1344,7 +1342,7 @@ else
1344
1342
  # double sequence this character to be
1345
1343
  # an escaped quote.
1346
1344
  # <b><tt>:encoding</tt></b>:: The encoding to use when parsing the
1347
- # file. Defaults to your <tt>$KDOCE</tt>
1345
+ # file. Defaults to your <tt>$KCODE</tt>
1348
1346
  # setting. Valid values: <tt>`n’</tt> or
1349
1347
  # <tt>`N’</tt> for none, <tt>`e’</tt> or
1350
1348
  # <tt>`E’</tt> for EUC, <tt>`s’</tt> or
@@ -1402,6 +1400,10 @@ else
1402
1400
  # through the converters).
1403
1401
  # <b><tt>:write_headers</tt></b>:: When +true+ and <tt>:headers</tt> is
1404
1402
  # set, a header row will be added to the
1403
+ # output. Note that if the table only
1404
+ # contains header rows,
1405
+ # <tt>:return_headers</tt> must also be
1406
+ # set in order for a header row to be
1405
1407
  # output.
1406
1408
  # <b><tt>:header_converters</tt></b>:: Identical in functionality to
1407
1409
  # <tt>:converters</tt> save that the
@@ -1638,8 +1640,10 @@ else
1638
1640
  field_quotes += match.count(@quote_char)
1639
1641
  if field_quotes % 2 == 0
1640
1642
  in_quotes = current_field[@parsers[:quoted_field], 1]
1641
- raise MalformedCSVError if !in_quotes ||
1642
- in_quotes[@parsers[:stray_quote]]
1643
+ if !in_quotes || in_quotes[@parsers[:stray_quote]]
1644
+ raise MalformedCSVError,
1645
+ "Missing or stray quote in line #{lineno + 1}"
1646
+ end
1643
1647
  current_field = in_quotes
1644
1648
  current_field.gsub!(@quote_char * 2, @quote_char) # unescape contents
1645
1649
  csv << current_field
@@ -1649,7 +1653,7 @@ else
1649
1653
  current_field << @col_sep
1650
1654
  end
1651
1655
  elsif match.count("\r\n").zero?
1652
- raise MalformedCSVError, "Illegal quoting on line #{lineno + 1}."
1656
+ raise MalformedCSVError, "Illegal quoting in line #{lineno + 1}."
1653
1657
  else
1654
1658
  raise MalformedCSVError, "Unquoted fields do not allow " +
1655
1659
  "\\r or \\n (line #{lineno + 1})."
@@ -1739,43 +1743,50 @@ else
1739
1743
 
1740
1744
  # automatically discover row separator when requested
1741
1745
  if @row_sep == :auto
1742
- if [ARGF, STDIN, STDOUT, STDERR].include?(@io) or
1743
- (defined?(Zlib) and @io.class == Zlib::GzipWriter)
1744
- @row_sep = $INPUT_RECORD_SEPARATOR
1745
- else
1746
- begin
1747
- saved_pos = @io.pos # remember where we were
1748
- while @row_sep == :auto
1749
- #
1750
- # if we run out of data, it's probably a single line
1751
- # (use a sensible default)
1752
- #
1753
- if @io.eof?
1754
- @row_sep = $INPUT_RECORD_SEPARATOR
1755
- break
1756
- end
1757
-
1758
- # read ahead a bit
1759
- sample = @io.read(1024)
1760
- sample += @io.read(1) if sample[-1..-1] == "\r" and not @io.eof?
1761
-
1762
- # try to find a standard separator
1763
- if sample =~ /\r\n?|\n/
1764
- @row_sep = $&
1765
- break
1766
- end
1767
- end
1768
- # tricky seek() clone to work around GzipReader's lack of seek()
1769
- @io.rewind
1770
- # reset back to the remembered position
1771
- while saved_pos > 1024 # avoid loading a lot of data into memory
1772
- @io.read(1024)
1773
- saved_pos -= 1024
1746
+ begin
1747
+ #
1748
+ # remember where we were (pos() will raise an axception if @io is pipe
1749
+ # or not opened for reading)
1750
+ #
1751
+ saved_pos = @io.pos
1752
+ while @row_sep == :auto
1753
+ #
1754
+ # if we run out of data, it's probably a single line
1755
+ # (ensure will set default value)
1756
+ #
1757
+ break if @io.eof?
1758
+
1759
+ # read ahead a bit
1760
+ sample = @io.read(1024)
1761
+ sample += @io.read(1) if sample[-1..-1] == "\r" and not @io.eof?
1762
+
1763
+ # try to find a standard separator
1764
+ if sample =~ /\r\n?|\n/
1765
+ @row_sep = $&
1766
+ break
1774
1767
  end
1775
- @io.read(saved_pos) if saved_pos.nonzero?
1776
- rescue IOError # stream not opened for reading
1777
- @row_sep = $INPUT_RECORD_SEPARATOR
1778
1768
  end
1769
+
1770
+ # tricky seek() clone to work around GzipReader's lack of seek()
1771
+ @io.rewind
1772
+ # reset back to the remembered position
1773
+ while saved_pos > 1024 # avoid loading a lot of data into memory
1774
+ @io.read(1024)
1775
+ saved_pos -= 1024
1776
+ end
1777
+ @io.read(saved_pos) if saved_pos.nonzero?
1778
+ rescue IOError # not opened for reading
1779
+ # do nothing: ensure will set default
1780
+ rescue NoMethodError # Zlib::GzipWriter doesn't have eof?
1781
+ # do nothing: ensure will set default
1782
+ rescue SystemCallError # pipe
1783
+ # do nothing: ensure will set default
1784
+ ensure
1785
+ #
1786
+ # set default if we failed to detect
1787
+ # (stream not opened for reading, a pipe, or a single line of data)
1788
+ #
1789
+ @row_sep = $INPUT_RECORD_SEPARATOR if @row_sep == :auto
1779
1790
  end
1780
1791
  end
1781
1792
 
@@ -3,7 +3,7 @@
3
3
  # fastercsv.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2006-04-01.
6
- # Copyright 2006 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
  #
8
8
  # This file is just another name for faster_csv.rb.
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_csv_parsing.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-10-31.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -185,7 +185,7 @@ class TestCSVParsing < Test::Unit::TestCase
185
185
  assert_send([csv.lineno, :<, 4])
186
186
  end
187
187
  rescue FasterCSV::MalformedCSVError
188
- assert_equal("Illegal quoting on line 4.", $!.message)
188
+ assert_equal("Illegal quoting in line 4.", $!.message)
189
189
  end
190
190
  end
191
191
  end
@@ -3,7 +3,7 @@
3
3
  # tc_csv_writing.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-11-14.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_data_converters.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-12-30.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_encodings.rb
4
4
  #
5
5
  # Created by Michael Reinsch.
6
- # Copyright (c) 2008 Ubiquitous Business Technology, Inc.
6
+ # Copyright (c) 2012 Ubiquitous Business Technology, Inc.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_features.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-11-14.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
  require "zlib"
@@ -3,7 +3,7 @@
3
3
  # tc_headers.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2006-02-25.
6
- # Copyright 2006 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_interface.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-11-14.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_row.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2006-02-24.
6
- # Copyright 2006 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_serialization.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2006-03-28.
6
- # Copyright 2006 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # tc_speed.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-11-14.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
  require "timeout"
@@ -3,7 +3,7 @@
3
3
  # tc_table.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2006-02-24.
6
- # Copyright 2006 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
@@ -3,7 +3,7 @@
3
3
  # ts_all.rb
4
4
  #
5
5
  # Created by James Edward Gray II on 2005-11-14.
6
- # Copyright 2005 Gray Productions. All rights reserved.
6
+ # Copyright 2012 Gray Productions. All rights reserved.
7
7
 
8
8
  require "test/unit"
9
9
 
metadata CHANGED
@@ -1,35 +1,28 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fastercsv
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 5
9
- - 4
10
- version: 1.5.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.5
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - James Edward Gray II
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-07 00:00:00 -06:00
19
- default_executable:
12
+ date: 2012-05-15 00:00:00.000000000 Z
20
13
  dependencies: []
14
+ description: ! 'FasterCSV is intended as a complete replacement to the CSV standard
15
+ library. It
21
16
 
22
- description: |
23
- FasterCSV is intended as a complete replacement to the CSV standard library. It
24
17
  is significantly faster and smaller while still being pure Ruby code. It also
18
+
25
19
  strives for a better interface.
26
20
 
21
+ '
27
22
  email: james@grayproductions.net
28
23
  executables: []
29
-
30
24
  extensions: []
31
-
32
- extra_rdoc_files:
25
+ extra_rdoc_files:
33
26
  - AUTHORS
34
27
  - COPYING
35
28
  - README
@@ -37,7 +30,7 @@ extra_rdoc_files:
37
30
  - TODO
38
31
  - CHANGELOG
39
32
  - LICENSE
40
- files:
33
+ files:
41
34
  - lib/faster_csv.rb
42
35
  - lib/fastercsv.rb
43
36
  - test/tc_csv_parsing.rb
@@ -61,7 +54,6 @@ files:
61
54
  - test/test_data.csv
62
55
  - examples/purchase.csv
63
56
  - Rakefile
64
- - setup.rb
65
57
  - test/line_endings.gz
66
58
  - AUTHORS
67
59
  - COPYING
@@ -70,42 +62,33 @@ files:
70
62
  - TODO
71
63
  - CHANGELOG
72
64
  - LICENSE
73
- has_rdoc: true
74
65
  homepage: http://fastercsv.rubyforge.org
75
66
  licenses: []
76
-
77
67
  post_install_message:
78
- rdoc_options:
68
+ rdoc_options:
79
69
  - --title
80
70
  - FasterCSV Documentation
81
71
  - --main
82
72
  - README
83
- require_paths:
73
+ require_paths:
84
74
  - lib
85
- required_ruby_version: !ruby/object:Gem::Requirement
75
+ required_ruby_version: !ruby/object:Gem::Requirement
86
76
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
82
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
103
87
  requirements: []
104
-
105
88
  rubyforge_project: fastercsv
106
- rubygems_version: 1.3.7
89
+ rubygems_version: 1.8.24
107
90
  signing_key:
108
91
  specification_version: 3
109
92
  summary: FasterCSV is CSV, but faster, smaller, and cleaner.
110
- test_files:
93
+ test_files:
111
94
  - test/ts_all.rb