nesquikcsv 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/ext/csv_parser/CsvParser.java +89 -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 +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e532ff04c08281fe68ca8a75fffd5ff666a4a810
|
4
|
+
data.tar.gz: a73bda5b01d8565662e40fac5a242b79d4f5c474
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec2b915c11e3ecff94696ec99b9c662218e556cc5caf4784a49afbf65fbfd2faa7fa568b466887f6d261d5fe63b0dc21f151bc8494c1308ef23c447a17d102df
|
7
|
+
data.tar.gz: 4fc060f7a7847f6ebfb5017ede5a2e3fe61ed26dbef1aafe781ad6c37002a9dcc32963fa05f8004d7fd1e097c540f3f4274d412fb8e30ddd2e31c1993c0a05b6
|
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/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,41 +1,41 @@
|
|
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: ruby
|
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
14
|
name: test-unit
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake-compiler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
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
40
|
version: '0'
|
41
41
|
description: Fastest-CSV fork with encoding support
|
@@ -46,11 +46,12 @@ extensions:
|
|
46
46
|
- ext/csv_parser/extconf.rb
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
-
- .gitignore
|
49
|
+
- ".gitignore"
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
|
+
- ext/csv_parser/CsvParser.java
|
54
55
|
- ext/csv_parser/extconf.rb
|
55
56
|
- ext/csv_parser/parser.c
|
56
57
|
- lib/nesquikcsv.rb
|
@@ -68,17 +69,17 @@ require_paths:
|
|
68
69
|
- lib
|
69
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
71
|
requirements:
|
71
|
-
- -
|
72
|
+
- - ">="
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
74
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
81
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.5.1
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: Fastest-CSV fork with encoding support
|