fastcsv 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +5 -3
- data/.yardopts +3 -0
- data/Gemfile +1 -1
- data/README.md +1 -2
- data/Rakefile +5 -5
- data/ext/fastcsv/fastcsv.c +545 -1129
- data/ext/fastcsv/fastcsv.rl +5 -5
- data/fastcsv.gemspec +3 -3
- data/lib/fastcsv.rb +1 -1
- data/spec/fastcsv_spec.rb +16 -1
- metadata +14 -29
- data/USAGE +0 -1
data/ext/fastcsv/fastcsv.rl
CHANGED
@@ -155,9 +155,9 @@ typedef struct {
|
|
155
155
|
EOF = 0;
|
156
156
|
quote_char = any when { fc == quote_char };
|
157
157
|
col_sep = any when { fc == col_sep } >new_field;
|
158
|
-
row_sep =
|
159
|
-
unquoted = (any* -- quote_char -- col_sep -- row_sep - EOF) %read_unquoted;
|
160
|
-
quoted = quote_char >open_quote (any - quote_char - EOF | quote_char quote_char
|
158
|
+
row_sep = '\r' '\n'? | '\n';
|
159
|
+
unquoted = (any* -- quote_char -- col_sep -- row_sep -- '\r' -- '\n' - EOF) %read_unquoted;
|
160
|
+
quoted = quote_char >open_quote (any - quote_char - EOF | quote_char quote_char)* %read_quoted quote_char >close_quote;
|
161
161
|
field = unquoted | quoted;
|
162
162
|
|
163
163
|
# @see Ragel Guide: 6.3 Scanners
|
@@ -253,7 +253,7 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
253
253
|
rb_raise(rb_eArgError, ":col_sep has to be a single character String");
|
254
254
|
}
|
255
255
|
|
256
|
-
// @see rb_io_extract_modeenc
|
256
|
+
// @see rb_io_extract_modeenc parse_mode_enc
|
257
257
|
/* Set to defaults */
|
258
258
|
rb_io_ext_int_to_encs(NULL, NULL, &enc, &enc2, 0);
|
259
259
|
|
@@ -473,7 +473,7 @@ static VALUE raw_parse(int argc, VALUE *argv, VALUE self) {
|
|
473
473
|
if (d->start > ts) {
|
474
474
|
d->start = buf + (d->start - ts);
|
475
475
|
}
|
476
|
-
if (mark_row_sep
|
476
|
+
if (mark_row_sep >= ts) {
|
477
477
|
mark_row_sep = buf + (mark_row_sep - ts);
|
478
478
|
}
|
479
479
|
te = buf + (te - ts);
|
data/fastcsv.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "fastcsv"
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.7'
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.authors = ["James McKinney"]
|
8
8
|
s.homepage = "https://github.com/jpmckinney/fastcsv"
|
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.extensions = ["ext/fastcsv/extconf.rb"]
|
17
17
|
|
18
18
|
s.add_development_dependency('coveralls')
|
19
|
-
s.add_development_dependency('json', '~> 1.8') # to silence coveralls warning
|
20
19
|
s.add_development_dependency('rake')
|
21
|
-
s.add_development_dependency('rake-compiler')
|
22
20
|
s.add_development_dependency('rspec', '~> 3.1')
|
21
|
+
|
22
|
+
s.add_development_dependency('rake-compiler')
|
23
23
|
end
|
data/lib/fastcsv.rb
CHANGED
@@ -123,7 +123,7 @@ private
|
|
123
123
|
encoding = enc
|
124
124
|
end
|
125
125
|
end
|
126
|
-
parser.raw_parse(@io, encoding: encoding, quote_char: quote_char, col_sep: col_sep) do |row|
|
126
|
+
parser.raw_parse(@io, encoding: encoding, quote_char: quote_char, col_sep: col_sep, row_sep: row_sep) do |row|
|
127
127
|
Fiber.yield(row)
|
128
128
|
end
|
129
129
|
end
|
data/spec/fastcsv_spec.rb
CHANGED
@@ -136,7 +136,14 @@ RSpec.shared_examples 'a CSV parser' do
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
it
|
139
|
+
it 'should raise the row number' do
|
140
|
+
csv = %("\n\n\n"\n"x)
|
141
|
+
csv_error = 'Unclosed quoted field on line 2.'
|
142
|
+
expect{CSV.parse(csv)}.to raise_error(CSV::MalformedCSVError, csv_error)
|
143
|
+
expect{parse(csv)}.to raise_error(FastCSV::MalformedCSVError, csv_error)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should parse an encoded string' do
|
140
147
|
csv = "ß"
|
141
148
|
actual = parse(csv)
|
142
149
|
expected = CSV.parse(csv)
|
@@ -181,6 +188,14 @@ RSpec.shared_examples 'a CSV parser' do
|
|
181
188
|
it 'should allow zero' do
|
182
189
|
expect(parse_with_buffer_size(simple, 0)).to eq(CSV.parse(simple))
|
183
190
|
end
|
191
|
+
|
192
|
+
it 'should parse a consecutive field-sep and row-sep at a buffer boundary' do
|
193
|
+
# This is a further minimized reproduction of
|
194
|
+
# https://github.com/jpmckinney/fastcsv/issues/14
|
195
|
+
csv = "A0,B0\nA1,B1,\nA2,B2,\n"
|
196
|
+
buffer_size = 4
|
197
|
+
expect(parse_with_buffer_size(csv, buffer_size)).to eq(CSV.parse(csv))
|
198
|
+
end
|
184
199
|
end
|
185
200
|
end
|
186
201
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastcsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James McKinney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.8'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.8'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,33 +39,33 @@ dependencies:
|
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
|
-
- - "
|
45
|
+
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '3.1'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
|
-
- - "
|
52
|
+
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '3.1'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: rake-compiler
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
61
|
+
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '0'
|
83
69
|
description:
|
84
70
|
email:
|
85
71
|
executables: []
|
@@ -90,12 +76,12 @@ files:
|
|
90
76
|
- ".gitignore"
|
91
77
|
- ".rspec"
|
92
78
|
- ".travis.yml"
|
79
|
+
- ".yardopts"
|
93
80
|
- Gemfile
|
94
81
|
- LICENSE
|
95
82
|
- README.md
|
96
83
|
- Rakefile
|
97
84
|
- TESTS.md
|
98
|
-
- USAGE
|
99
85
|
- ext/fastcsv/extconf.rb
|
100
86
|
- ext/fastcsv/fastcsv.c
|
101
87
|
- ext/fastcsv/fastcsv.rl
|
@@ -141,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
127
|
- !ruby/object:Gem::Version
|
142
128
|
version: '0'
|
143
129
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.2.2
|
130
|
+
rubygems_version: 3.0.3.1
|
146
131
|
signing_key:
|
147
132
|
specification_version: 4
|
148
133
|
summary: A fast Ragel-based CSV parser, compatible with Ruby's CSV
|
data/USAGE
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
See README.md for full usage details.
|