nesquikcsv 0.1.0 → 0.1.1
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/ext/csv_parser/parser.c +2 -2
- data/lib/csv_parser.so +0 -0
- data/lib/nesquikcsv/version.rb +1 -1
- data/lib/nesquikcsv.rb +2 -1
- data/test/tc_csv_parsing.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8e84b01e1c81cf63e27c87bc0f37225431dcfbe
|
4
|
+
data.tar.gz: 685ca38bd86618cf1cf896f726c02c1757398a61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c04fe921fb15442cc727ad15354a48dc55e63b27ce04cd553e31e54e50c299bec08bb2ebdb2cf11659ff5183a19a50be3c3b1d0df3db1ca5a2ed3e229d45a97d
|
7
|
+
data.tar.gz: 50ce1b7cd325b7397b88189367172e1d59fe338a5ba6f1ba34d93e6f27443ebf0a9a30aeaf2b17f41ebec20fcba3ca9a353ba50ff7b09e132b61edf31c35b467
|
data/ext/csv_parser/parser.c
CHANGED
@@ -47,14 +47,14 @@ static VALUE parse_line(VALUE self, VALUE str, VALUE encoding)
|
|
47
47
|
{
|
48
48
|
case ',':
|
49
49
|
if (state == UNQUOTED) {
|
50
|
-
rb_ary_push(array, (index == 0 ? Qnil:
|
50
|
+
rb_ary_push(array, (index == 0 ? Qnil: rb_enc_str_new(value, index, rb_encoding)));
|
51
51
|
index = 0;
|
52
52
|
}
|
53
53
|
else if (state == IN_QUOTED) {
|
54
54
|
value[index++] = c;
|
55
55
|
}
|
56
56
|
else if (state == QUOTE_IN_QUOTED) {
|
57
|
-
rb_ary_push(array,
|
57
|
+
rb_ary_push(array, rb_enc_str_new(value, index, rb_encoding));
|
58
58
|
index = 0;
|
59
59
|
state = UNQUOTED;
|
60
60
|
}
|
data/lib/csv_parser.so
CHANGED
Binary file
|
data/lib/nesquikcsv/version.rb
CHANGED
data/lib/nesquikcsv.rb
CHANGED
@@ -54,7 +54,8 @@ class NesquikCSV
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def self.parse_line(line, encoding)
|
57
|
-
CsvParser.parse_line(line, encoding)
|
57
|
+
r = CsvParser.parse_line(line, encoding)
|
58
|
+
r.map {|e| e.force_encoding(encoding) unless e.nil?} unless r.nil?
|
58
59
|
end
|
59
60
|
|
60
61
|
# Create new NesquikCSV wrapping the specified IO object
|
data/test/tc_csv_parsing.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
#
|
2
3
|
# Tests copied from faster_csv by James Edward Gray II
|
3
4
|
#
|
@@ -123,4 +124,8 @@ class TestCSVParsing < Test::Unit::TestCase
|
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
127
|
+
def test_encoding
|
128
|
+
assert_equal(["ñ","ó","¸"], CsvParser.parse_line("ñ,ó,¸", "UTF-8"))
|
129
|
+
end
|
130
|
+
|
126
131
|
end
|