File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -2586,7 +2586,14 @@ def each(&block)
2586
2586
# # Raises IOError (not opened for reading)
2587
2587
# csv.read
2588
2588
def read
2589
- rows = to_a
2589
+ rows = [ ]
2590
+ enumerator = parser_enumerator
2591
+ begin
2592
+ while true
2593
+ rows << enumerator . next
2594
+ end
2595
+ rescue StopIteration
2596
+ end
2590
2597
if parser . use_headers?
2591
2598
Table . new ( rows , headers : parser . headers )
2592
2599
else
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: false
3
+
4
+ require_relative "../helper"
5
+
6
+ class TestCSVParseRead < Test ::Unit ::TestCase
7
+ extend DifferentOFS
8
+
9
+ def test_shift
10
+ data = <<-CSV
11
+ 1
12
+ 2
13
+ 3
14
+ CSV
15
+ csv = CSV . new ( data )
16
+ assert_equal ( [
17
+ [ "1" ] ,
18
+ [ [ "2" ] , [ "3" ] ] ,
19
+ nil ,
20
+ ] ,
21
+ [
22
+ csv . shift ,
23
+ csv . read ,
24
+ csv . shift ,
25
+ ] )
26
+ end
27
+ end
You can’t perform that action at this time.
0 commit comments