fastcsv 0.0.6 → 0.0.8

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.
@@ -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 = ('\r' '\n'? | '\n');
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 | row_sep)* %read_quoted quote_char >close_quote;
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 > ts) {
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.6'
5
+ s.version = '0.0.8'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["James McKinney"]
8
8
  s.homepage = "https://github.com/jpmckinney/fastcsv"
@@ -15,9 +15,11 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = ["lib"]
16
16
  s.extensions = ["ext/fastcsv/extconf.rb"]
17
17
 
18
+ s.add_runtime_dependency('csv')
19
+
18
20
  s.add_development_dependency('coveralls')
19
- s.add_development_dependency('json', '~> 1.8') # to silence coveralls warning
20
21
  s.add_development_dependency('rake')
21
- s.add_development_dependency('rake-compiler')
22
22
  s.add_development_dependency('rspec', '~> 3.1')
23
+
24
+ s.add_development_dependency('rake-compiler')
23
25
  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 "should parse an encoded string" do
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,23 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastcsv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - James McKinney
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2025-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: coveralls
14
+ name: csv
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :development
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: json
28
+ name: coveralls
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.8'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,35 +53,35 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake-compiler
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.1'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: rake-compiler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3.1'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3.1'
83
- description:
84
- email:
82
+ version: '0'
83
+ description:
84
+ email:
85
85
  executables: []
86
86
  extensions:
87
87
  - ext/fastcsv/extconf.rb
@@ -90,12 +90,12 @@ files:
90
90
  - ".gitignore"
91
91
  - ".rspec"
92
92
  - ".travis.yml"
93
+ - ".yardopts"
93
94
  - Gemfile
94
95
  - LICENSE
95
96
  - README.md
96
97
  - Rakefile
97
98
  - TESTS.md
98
- - USAGE
99
99
  - ext/fastcsv/extconf.rb
100
100
  - ext/fastcsv/fastcsv.c
101
101
  - ext/fastcsv/fastcsv.rl
@@ -126,7 +126,7 @@ homepage: https://github.com/jpmckinney/fastcsv
126
126
  licenses:
127
127
  - MIT
128
128
  metadata: {}
129
- post_install_message:
129
+ post_install_message:
130
130
  rdoc_options: []
131
131
  require_paths:
132
132
  - lib
@@ -141,9 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubyforge_project:
145
- rubygems_version: 2.2.2
146
- signing_key:
144
+ rubygems_version: 3.5.21
145
+ signing_key:
147
146
  specification_version: 4
148
147
  summary: A fast Ragel-based CSV parser, compatible with Ruby's CSV
149
148
  test_files:
data/USAGE DELETED
@@ -1 +0,0 @@
1
- See README.md for full usage details.