nesquikcsv 0.1.6-java → 0.1.7-java
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/ext/csv_parser/CsvParser.java +89 -0
- data/lib/csv_parser.jar +0 -0
- data/lib/nesquikcsv/version.rb +1 -1
- data/lib/nesquikcsv.rb +8 -13
- data/nesquikcsv.gemspec +1 -0
- data/test/tc_csv_parsing.rb +122 -125
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbc244bfa0588d12fcfa0254677cb456884544f2
|
4
|
+
data.tar.gz: d47f2aae0c71b27494df777ba41649c47666d1d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb5895ae76a051b8740d6641190e00914181ada5701f51bcc80eb8a64ce11c6d597cfd1a43b20e14de1a6403dcf54d7a39b3c0d5277301114771f90d49bb302
|
7
|
+
data.tar.gz: a621bcbe880b777d2edaa23b15dd76187ef1bac1bff38a555722e6a1f7226da0c585d32f349c29be02dc88bb8e7540c4c799f7bbfc979544846d8f7732b3b392
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Fork of the Fastest-CSV gem to support any encoding, using UTF-8 by default.
|
4
4
|
|
5
|
-
Uses native C code to parse CSV lines in MRI Ruby
|
5
|
+
Uses native C code to parse CSV lines in MRI Ruby, falls back to standard library CSV parser for JRuby
|
6
6
|
|
7
7
|
Supports standard CSV according to RFC4180. Not the so-called "csv" from Excel.
|
8
8
|
|
data/Rakefile
CHANGED
@@ -4,7 +4,8 @@ require "bundler/gem_tasks"
|
|
4
4
|
spec = Gem::Specification.load('nesquikcsv.gemspec')
|
5
5
|
|
6
6
|
if RUBY_PLATFORM =~ /java/
|
7
|
-
|
7
|
+
require 'rake/javaextensiontask'
|
8
|
+
Rake::JavaExtensionTask.new('csv_parser', spec)
|
8
9
|
else
|
9
10
|
require 'rake/extensiontask'
|
10
11
|
Rake::ExtensionTask.new('csv_parser', spec)
|
@@ -27,3 +28,4 @@ Rake::TestTask.new do |t|
|
|
27
28
|
#test.verbose = true
|
28
29
|
end
|
29
30
|
|
31
|
+
task :default => [:test]
|
@@ -0,0 +1,89 @@
|
|
1
|
+
//
|
2
|
+
// Copyright (c) Maarten Oelering, BrightCode BV
|
3
|
+
//
|
4
|
+
|
5
|
+
package org.brightcode;
|
6
|
+
|
7
|
+
import java.util.ArrayList;
|
8
|
+
import java.util.List;
|
9
|
+
|
10
|
+
public class CsvParser {
|
11
|
+
|
12
|
+
private static int DEF_ARRAY_LEN = 32;
|
13
|
+
|
14
|
+
private static int UNQUOTED = 0;
|
15
|
+
private static int IN_QUOTED = 1;
|
16
|
+
private static int QUOTE_IN_QUOTED = 2;
|
17
|
+
|
18
|
+
public static List parseLine(String line, String encoding) {
|
19
|
+
int length = line.length();
|
20
|
+
if (length == 0)
|
21
|
+
return null;
|
22
|
+
|
23
|
+
int state = UNQUOTED;
|
24
|
+
StringBuilder value = new StringBuilder(length); // field value, no longer than line
|
25
|
+
List<String> array = new ArrayList<String>(DEF_ARRAY_LEN);
|
26
|
+
|
27
|
+
for (int i = 0; i < length; i++) {
|
28
|
+
char c = line.charAt(i);
|
29
|
+
switch (c) {
|
30
|
+
case ',':
|
31
|
+
if (state == UNQUOTED) {
|
32
|
+
if (value.length() == 0) {
|
33
|
+
array.add(null);
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
array.add(value.toString());
|
37
|
+
value.setLength(0);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
else if (state == IN_QUOTED) {
|
41
|
+
value.append(c);
|
42
|
+
}
|
43
|
+
else if (state == QUOTE_IN_QUOTED) {
|
44
|
+
array.add(value.toString());
|
45
|
+
value.setLength(0);
|
46
|
+
state = UNQUOTED;
|
47
|
+
}
|
48
|
+
break;
|
49
|
+
case '"':
|
50
|
+
if (state == UNQUOTED) {
|
51
|
+
state = IN_QUOTED;
|
52
|
+
}
|
53
|
+
else if (state == IN_QUOTED) {
|
54
|
+
state = QUOTE_IN_QUOTED;
|
55
|
+
}
|
56
|
+
else if (state == QUOTE_IN_QUOTED) {
|
57
|
+
value.append(c); // escaped quote
|
58
|
+
state = IN_QUOTED;
|
59
|
+
}
|
60
|
+
break;
|
61
|
+
case '\r':
|
62
|
+
case '\n':
|
63
|
+
if (state == IN_QUOTED) {
|
64
|
+
value.append(c);
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
i = length; // only parse first line if multiline
|
68
|
+
}
|
69
|
+
break;
|
70
|
+
default:
|
71
|
+
value.append(c);
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
if (state == UNQUOTED) {
|
76
|
+
if (value.length() == 0) {
|
77
|
+
array.add(null);
|
78
|
+
}
|
79
|
+
else {
|
80
|
+
array.add(value.toString());
|
81
|
+
value.setLength(0);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
else if (state == QUOTE_IN_QUOTED) {
|
85
|
+
array.add(value.toString());
|
86
|
+
}
|
87
|
+
return array;
|
88
|
+
}
|
89
|
+
}
|
data/lib/csv_parser.jar
ADDED
Binary file
|
data/lib/nesquikcsv/version.rb
CHANGED
data/lib/nesquikcsv.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
|
2
|
-
require 'csv'
|
3
|
-
else
|
4
|
-
require 'csv_parser'
|
5
|
-
end
|
1
|
+
require 'csv_parser'
|
6
2
|
require 'stringio'
|
7
3
|
|
8
4
|
# Fast CSV parser using native code
|
9
5
|
class NesquikCSV
|
10
6
|
include Enumerable
|
7
|
+
|
8
|
+
if RUBY_PLATFORM =~ /java/
|
9
|
+
include_package "org.brightcode"
|
10
|
+
end
|
11
11
|
|
12
12
|
# Pass each line of the specified +path+ as array to the provided +block+
|
13
13
|
def self.foreach(path, &block)
|
@@ -57,10 +57,9 @@ class NesquikCSV
|
|
57
57
|
|
58
58
|
def self.parse_line(line, encoding="UTF-8")
|
59
59
|
if RUBY_PLATFORM =~ /java/
|
60
|
-
|
61
|
-
else
|
62
|
-
CsvParser.parse_line(line, encoding)
|
60
|
+
line = line.force_encoding(encoding)
|
63
61
|
end
|
62
|
+
CsvParser.parse_line(line, encoding)
|
64
63
|
end
|
65
64
|
|
66
65
|
# Create new NesquikCSV wrapping the specified IO object
|
@@ -96,11 +95,7 @@ class NesquikCSV
|
|
96
95
|
# Read next line from the wrapped IO and return as array or nil at EOF
|
97
96
|
def shift(encoding='UTF-8')
|
98
97
|
if line = get_line_with_quotes
|
99
|
-
|
100
|
-
CSV.parse_line(line.force_encoding(encoding))
|
101
|
-
else
|
102
|
-
CsvParser.parse_line(line, encoding)
|
103
|
-
end
|
98
|
+
CsvParser.parse_line(line, encoding)
|
104
99
|
else
|
105
100
|
nil
|
106
101
|
end
|
data/nesquikcsv.gemspec
CHANGED
data/test/tc_csv_parsing.rb
CHANGED
@@ -3,144 +3,141 @@
|
|
3
3
|
# Tests copied from faster_csv by James Edward Gray II
|
4
4
|
#
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
# These tests dont make sense for jruby since there's no Java extension
|
9
|
-
else
|
6
|
+
require 'test/unit'
|
7
|
+
require 'nesquikcsv'
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
#
|
10
|
+
# Following tests are my interpretation of the
|
11
|
+
# {CSV RCF}[http://www.ietf.org/rfc/rfc4180.txt]. I only deviate from that
|
12
|
+
# document in one place (intentionally) and that is to make the default row
|
13
|
+
# separator <tt>$/</tt>.
|
14
|
+
#
|
15
|
+
class TestCSVParsing < Test::Unit::TestCase
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# document in one place (intentionally) and that is to make the default row
|
18
|
-
# separator <tt>$/</tt>.
|
19
|
-
#
|
20
|
-
class TestCSVParsing < Test::Unit::TestCase
|
21
|
-
|
22
|
-
def test_mastering_regex_example
|
23
|
-
ex = %Q{Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K}
|
24
|
-
assert_equal( [ "Ten Thousand", "10000", " 2710 ", nil, "10,000",
|
25
|
-
"It's \"10 Grand\", baby", "10K" ],
|
26
|
-
CsvParser.parse_line(ex, "UTF-8") )
|
27
|
-
end
|
28
|
-
|
29
|
-
# Pulled from: http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/test/csv/test_csv.rb?rev=1.12.2.2;content-type=text%2Fplain
|
30
|
-
def test_std_lib_csv
|
31
|
-
[ ["\t", ["\t"]],
|
32
|
-
["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
|
33
|
-
["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
|
34
|
-
["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
|
35
|
-
["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
|
36
|
-
["\"\"", [""]],
|
37
|
-
["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
|
38
|
-
["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
|
39
|
-
["foo,\"\r\",baz", ["foo", "\r", "baz"]],
|
40
|
-
["foo,\"\",baz", ["foo", "", "baz"]],
|
41
|
-
["\",\"", [","]],
|
42
|
-
["foo", ["foo"]],
|
43
|
-
[",,", [nil, nil, nil]],
|
44
|
-
[",", [nil, nil]],
|
45
|
-
["foo,\"\n\",baz", ["foo", "\n", "baz"]],
|
46
|
-
["foo,,baz", ["foo", nil, "baz"]],
|
47
|
-
["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
|
48
|
-
["\",\",\",\"", [",", ","]],
|
49
|
-
["foo,bar,", ["foo", "bar", nil]],
|
50
|
-
[",foo,bar", [nil, "foo", "bar"]],
|
51
|
-
["foo,bar", ["foo", "bar"]],
|
52
|
-
[";", [";"]],
|
53
|
-
["\t,\t", ["\t", "\t"]],
|
54
|
-
["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
|
55
|
-
["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
|
56
|
-
["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
|
57
|
-
[";,;", [";", ";"]] ].each do |csv_test|
|
58
|
-
assert_equal(csv_test.last, CsvParser.parse_line(csv_test.first, "UTF-8"))
|
59
|
-
end
|
60
|
-
|
61
|
-
[ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
|
62
|
-
["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
|
63
|
-
["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
|
64
|
-
["\"\"", [""]],
|
65
|
-
["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
|
66
|
-
["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
|
67
|
-
["foo,\"\r\",baz", ["foo", "\r", "baz"]],
|
68
|
-
["foo,\"\",baz", ["foo", "", "baz"]],
|
69
|
-
["foo", ["foo"]],
|
70
|
-
[",,", [nil, nil, nil]],
|
71
|
-
[",", [nil, nil]],
|
72
|
-
["foo,\"\n\",baz", ["foo", "\n", "baz"]],
|
73
|
-
["foo,,baz", ["foo", nil, "baz"]],
|
74
|
-
["foo,bar", ["foo", "bar"]],
|
75
|
-
["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
|
76
|
-
["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]] ].each do |csv_test|
|
77
|
-
assert_equal(csv_test.last, CsvParser.parse_line(csv_test.first, "UTF-8"))
|
78
|
-
end
|
79
|
-
end
|
17
|
+
if RUBY_PLATFORM =~ /java/
|
18
|
+
include_package "org.brightcode"
|
19
|
+
end
|
80
20
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
[%Q{a,"\nb"""}, ["a", "\nb\""]],
|
88
|
-
[%Q{a,"""\nb"}, ["a", "\"\nb"]],
|
89
|
-
[%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
|
90
|
-
[%Q{a,"""\nb\n""",\nc}, ["a", "\"\nb\n\"", nil]],
|
91
|
-
[%Q{a,,,}, ["a", nil, nil, nil]],
|
92
|
-
[%Q{,}, [nil, nil]],
|
93
|
-
[%Q{"",""}, ["", ""]],
|
94
|
-
[%Q{""""}, ["\""]],
|
95
|
-
[%Q{"""",""}, ["\"",""]],
|
96
|
-
[%Q{,""}, [nil,""]],
|
97
|
-
[%Q{,"\r"}, [nil,"\r"]],
|
98
|
-
[%Q{"\r\n,"}, ["\r\n,"]],
|
99
|
-
[%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |edge_case|
|
100
|
-
assert_equal(edge_case.last, CsvParser.parse_line(edge_case.first, "UTF-8"))
|
101
|
-
end
|
102
|
-
end
|
21
|
+
def test_mastering_regex_example
|
22
|
+
ex = %Q{Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K}
|
23
|
+
assert_equal( [ "Ten Thousand", "10000", " 2710 ", nil, "10,000",
|
24
|
+
"It's \"10 Grand\", baby", "10K" ],
|
25
|
+
CsvParser.parse_line(ex, "UTF-8") )
|
26
|
+
end
|
103
27
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
28
|
+
# Pulled from: http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/ruby/test/csv/test_csv.rb?rev=1.12.2.2;content-type=text%2Fplain
|
29
|
+
def test_std_lib_csv
|
30
|
+
[ ["\t", ["\t"]],
|
31
|
+
["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
|
32
|
+
["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
|
33
|
+
["\"\"\"\n\",\"\"\"\n\"", ["\"\n", "\"\n"]],
|
34
|
+
["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
|
35
|
+
["\"\"", [""]],
|
36
|
+
["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
|
37
|
+
["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
|
38
|
+
["foo,\"\r\",baz", ["foo", "\r", "baz"]],
|
39
|
+
["foo,\"\",baz", ["foo", "", "baz"]],
|
40
|
+
["\",\"", [","]],
|
41
|
+
["foo", ["foo"]],
|
42
|
+
[",,", [nil, nil, nil]],
|
43
|
+
[",", [nil, nil]],
|
44
|
+
["foo,\"\n\",baz", ["foo", "\n", "baz"]],
|
45
|
+
["foo,,baz", ["foo", nil, "baz"]],
|
46
|
+
["\"\"\"\r\",\"\"\"\r\"", ["\"\r", "\"\r"]],
|
47
|
+
["\",\",\",\"", [",", ","]],
|
48
|
+
["foo,bar,", ["foo", "bar", nil]],
|
49
|
+
[",foo,bar", [nil, "foo", "bar"]],
|
50
|
+
["foo,bar", ["foo", "bar"]],
|
51
|
+
[";", [";"]],
|
52
|
+
["\t,\t", ["\t", "\t"]],
|
53
|
+
["foo,\"\r\n\r\",baz", ["foo", "\r\n\r", "baz"]],
|
54
|
+
["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
|
55
|
+
["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]],
|
56
|
+
[";,;", [";", ";"]] ].each do |csv_test|
|
57
|
+
assert_equal(csv_test.last, CsvParser.parse_line(csv_test.first, "UTF-8"))
|
114
58
|
end
|
59
|
+
|
60
|
+
[ ["foo,\"\"\"\"\"\",baz", ["foo", "\"\"", "baz"]],
|
61
|
+
["foo,\"\"\"bar\"\"\",baz", ["foo", "\"bar\"", "baz"]],
|
62
|
+
["foo,\"\r\n\",baz", ["foo", "\r\n", "baz"]],
|
63
|
+
["\"\"", [""]],
|
64
|
+
["foo,\"\"\"\",baz", ["foo", "\"", "baz"]],
|
65
|
+
["foo,\"\r.\n\",baz", ["foo", "\r.\n", "baz"]],
|
66
|
+
["foo,\"\r\",baz", ["foo", "\r", "baz"]],
|
67
|
+
["foo,\"\",baz", ["foo", "", "baz"]],
|
68
|
+
["foo", ["foo"]],
|
69
|
+
[",,", [nil, nil, nil]],
|
70
|
+
[",", [nil, nil]],
|
71
|
+
["foo,\"\n\",baz", ["foo", "\n", "baz"]],
|
72
|
+
["foo,,baz", ["foo", nil, "baz"]],
|
73
|
+
["foo,bar", ["foo", "bar"]],
|
74
|
+
["foo,\"\r\n\n\",baz", ["foo", "\r\n\n", "baz"]],
|
75
|
+
["foo,\"foo,bar\",baz", ["foo", "foo,bar", "baz"]] ].each do |csv_test|
|
76
|
+
assert_equal(csv_test.last, CsvParser.parse_line(csv_test.first, "UTF-8"))
|
77
|
+
end
|
78
|
+
end
|
115
79
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
]
|
80
|
+
# From: http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-core/6496
|
81
|
+
def test_aras_edge_cases
|
82
|
+
[ [%Q{a,b}, ["a", "b"]],
|
83
|
+
[%Q{a,"""b"""}, ["a", "\"b\""]],
|
84
|
+
[%Q{a,"""b"}, ["a", "\"b"]],
|
85
|
+
[%Q{a,"b"""}, ["a", "b\""]],
|
86
|
+
[%Q{a,"\nb"""}, ["a", "\nb\""]],
|
87
|
+
[%Q{a,"""\nb"}, ["a", "\"\nb"]],
|
88
|
+
[%Q{a,"""\nb\n"""}, ["a", "\"\nb\n\""]],
|
89
|
+
[%Q{a,"""\nb\n""",\nc}, ["a", "\"\nb\n\"", nil]],
|
90
|
+
[%Q{a,,,}, ["a", nil, nil, nil]],
|
91
|
+
[%Q{,}, [nil, nil]],
|
92
|
+
[%Q{"",""}, ["", ""]],
|
93
|
+
[%Q{""""}, ["\""]],
|
94
|
+
[%Q{"""",""}, ["\"",""]],
|
95
|
+
[%Q{,""}, [nil,""]],
|
96
|
+
[%Q{,"\r"}, [nil,"\r"]],
|
97
|
+
[%Q{"\r\n,"}, ["\r\n,"]],
|
98
|
+
[%Q{"\r\n,",}, ["\r\n,", nil]] ].each do |edge_case|
|
128
99
|
assert_equal(edge_case.last, CsvParser.parse_line(edge_case.first, "UTF-8"))
|
129
100
|
end
|
130
|
-
|
101
|
+
end
|
131
102
|
|
132
|
-
|
133
|
-
|
134
|
-
|
103
|
+
def test_james_edge_cases
|
104
|
+
# A read at eof? should return nil.
|
105
|
+
assert_equal(nil, CsvParser.parse_line("", "UTF-8"))
|
106
|
+
#
|
107
|
+
# With CSV it's impossible to tell an empty line from a line containing a
|
108
|
+
# single +nil+ field. The standard CSV library returns <tt>[nil]</tt>
|
109
|
+
# in these cases, but <tt>Array.new</tt> makes more sense to me.
|
110
|
+
#
|
111
|
+
#assert_equal(Array.new, NesquikCSV.parse_line("\n1,2,3\n"))
|
112
|
+
assert_equal([nil], CsvParser.parse_line("\n1,2,3\n", "UTF-8"))
|
113
|
+
end
|
135
114
|
|
136
|
-
|
137
|
-
|
115
|
+
def test_rob_edge_cases
|
116
|
+
[ [%Q{"a\nb"}, ["a\nb"]],
|
117
|
+
[%Q{"\n\n\n"}, ["\n\n\n"]],
|
118
|
+
[%Q{a,"b\n\nc"}, ['a', "b\n\nc"]],
|
119
|
+
[%Q{,"\r\n"}, [nil,"\r\n"]],
|
120
|
+
[%Q{,"\r\n."}, [nil,"\r\n."]],
|
121
|
+
[%Q{"a\na","one newline"}, ["a\na", 'one newline']],
|
122
|
+
[%Q{"a\n\na","two newlines"}, ["a\n\na", 'two newlines']],
|
123
|
+
[%Q{"a\r\na","one CRLF"}, ["a\r\na", 'one CRLF']],
|
124
|
+
[%Q{"a\r\n\r\na","two CRLFs"}, ["a\r\n\r\na", 'two CRLFs']],
|
125
|
+
[%Q{with blank,"start\n\nfinish"\n}, ['with blank', "start\n\nfinish"]],
|
126
|
+
].each do |edge_case|
|
127
|
+
assert_equal(edge_case.last, CsvParser.parse_line(edge_case.first, "UTF-8"))
|
138
128
|
end
|
129
|
+
end
|
139
130
|
|
140
|
-
|
141
|
-
|
142
|
-
|
131
|
+
def test_encoding
|
132
|
+
assert_equal(["ñ","ó","¸"], CsvParser.parse_line("ñ,ó,¸", "UTF-8"))
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_quoted_line_break
|
136
|
+
assert_equal(["foo","bar,baz\nbeam","bee"], CsvParser.parse_line("foo,\"bar,baz\nbeam\",bee", "UTF-8"))
|
137
|
+
end
|
143
138
|
|
139
|
+
def test_quoted_line_break_at_end
|
140
|
+
assert_equal(["foo","bar,baz\n","bee"], CsvParser.parse_line("foo,\"bar,baz\n\",bee", "UTF-8"))
|
144
141
|
end
|
145
142
|
|
146
143
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nesquikcsv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Juan Martty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: test-unit
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
14
|
requirement: !ruby/object:Gem::Requirement
|
21
15
|
requirements:
|
22
16
|
- - '>='
|
23
17
|
- !ruby/object:Gem::Version
|
24
18
|
version: '0'
|
19
|
+
name: test-unit
|
25
20
|
prerelease: false
|
26
21
|
type: :development
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake-compiler
|
29
22
|
version_requirements: !ruby/object:Gem::Requirement
|
30
23
|
requirements:
|
31
24
|
- - '>='
|
32
25
|
- !ruby/object:Gem::Version
|
33
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
35
29
|
requirements:
|
36
30
|
- - '>='
|
37
31
|
- !ruby/object:Gem::Version
|
38
32
|
version: '0'
|
33
|
+
name: rake-compiler
|
39
34
|
prerelease: false
|
40
35
|
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
41
|
description: Fastest-CSV fork with encoding support
|
42
42
|
email:
|
43
43
|
- null.terminated.string@gmail.com
|
@@ -50,8 +50,10 @@ files:
|
|
50
50
|
- LICENSE
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
+
- ext/csv_parser/CsvParser.java
|
53
54
|
- ext/csv_parser/extconf.rb
|
54
55
|
- ext/csv_parser/parser.c
|
56
|
+
- lib/csv_parser.jar
|
55
57
|
- lib/nesquikcsv.rb
|
56
58
|
- lib/nesquikcsv/version.rb
|
57
59
|
- nesquikcsv.gemspec
|