Permalink
Browse files

Fix the EOL auto-discovery logic

so that it could work inside pipes, like

  $ ./some_faster_csv_script.rb < file.csv
  • Loading branch information...
alexis committed May 30, 2011
1 parent cd9c813 commit 77a894088bcf0f6140ef230488f0f260a24f7130
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/faster_csv.rb
View
@@ -1318,9 +1318,7 @@ def self.table(path, options = Hash.new)
# even if it occurs in a quoted field,
# assuming that you would have the same
# line endings there. If none of those
- # sequences is found, +data+ is
- # <tt>ARGF</tt>, <tt>STDIN</tt>,
- # <tt>STDOUT</tt>, or <tt>STDERR</tt>,
+ # sequences is found,
# or the stream is only available for
# output, the default
# <tt>$INPUT_RECORD_SEPARATOR</tt>
@@ -1745,8 +1743,7 @@ def init_separators(options)
# automatically discover row separator when requested
if @row_sep == :auto
- if [ARGF, STDIN, STDOUT, STDERR].include?(@io) or
- (defined?(Zlib) and @io.class == Zlib::GzipWriter)
+ if !@io.respond_to?(:eof?) or (@io.eof? rescue true) # we can't auto-discover for STDOUT, STDERR, Zlib::GzipWriter streems, etc
@row_sep = $INPUT_RECORD_SEPARATOR
else
begin

0 comments on commit 77a8940

Please sign in to comment.