dsv 0.12.5 → 0.12.6
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/CHANGELOG +8 -0
- data/lib/DSV/VERSION.rb +1 -1
- data/test/dsv_test.rb +27 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7322674ac0843543bf2f813312290dd2c4d460c7c3d0e8e8d604ccfcb680a196
|
|
4
|
+
data.tar.gz: 866e0a95d7854265444854111c0f1b61ed5e0faf9eb1f55ba20061f60fe52447
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 219226e29fa873569b197d731813421aa478d18719bb25ede6501b84ab42efd574112a1131c7e3526933fe5099c8c1c3fffb8345d1fcdb26392dd8ef9fe445c9
|
|
7
|
+
data.tar.gz: e57b19a5fc7ce1855f4fd40cca7a496bd946464c43f84e00e13f8a3b031d2e8b7c104e6995e749d2955a968c941896d80951f8190f557ff17ea92734c65aba66
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# dsv/CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20261027
|
|
4
|
+
|
|
5
|
+
0.12.6: + quoting examples.
|
|
6
|
+
|
|
7
|
+
1. ~ test/dsv_test.rb: + a doubled quote before a separator, skipped; + a quote not opening a field read as data; + a stray quote not taking in the next line, skipped; + an unclosed quoted field raising UnterminatedQuote, skipped.
|
|
8
|
+
2. ~ lib/DSV/VERSION.rb: /0.12.5/0.12.6/.
|
|
9
|
+
|
|
10
|
+
|
|
3
11
|
## 20261016
|
|
4
12
|
|
|
5
13
|
0.12.5: Regexp separators and quote: :double made to do what the README says.
|
data/lib/DSV/VERSION.rb
CHANGED
data/test/dsv_test.rb
CHANGED
|
@@ -242,6 +242,13 @@ describe DSV do
|
|
|
242
242
|
_(DSV.parse_line('foo,"""""",baz')).must_equal ['foo', '""', 'baz']
|
|
243
243
|
end
|
|
244
244
|
|
|
245
|
+
it "reads a doubled quote just before a separator inside a quoted field" do
|
|
246
|
+
skip "Observation: a piece of a quoted field ending in a quote is taken as the field's end, an escaped quote ending in one as a closing quote does"
|
|
247
|
+
_(DSV.parse_line('"He said ""no"", then left",x')).must_equal ['He said "no", then left', 'x']
|
|
248
|
+
_(DSV.parse_line('"a"",""b",c')).must_equal ['a","b', 'c']
|
|
249
|
+
_(DSV.read("\"a\"\",\"\"b\",\"c\"\n", quote: :double)).must_equal [{0 => 'a","b', 1 => 'c'}]
|
|
250
|
+
end
|
|
251
|
+
|
|
245
252
|
it "reads a trailing empty field as an empty string" do
|
|
246
253
|
_(DSV.parse_line('foo,bar,')).must_equal ['foo', 'bar', '']
|
|
247
254
|
_(DSV.parse_line(',')).must_equal ['', '']
|
|
@@ -548,6 +555,26 @@ describe DSV do
|
|
|
548
555
|
end
|
|
549
556
|
end
|
|
550
557
|
|
|
558
|
+
# Input which is not RFC 4180, read to one rule provisionally, until a policy for malformed quoting is decided: a quote is structure only where it opens a field, and a field it opens which does not close raises UnterminatedQuote.
|
|
559
|
+
describe "quoting on read, where the input is malformed" do
|
|
560
|
+
it "reads a quote which does not open a field as data" do
|
|
561
|
+
_(DSV.parse_line('a"b"c,d')).must_equal ['a"b"c', 'd']
|
|
562
|
+
_(DSV.parse_line('a, "b,c"')).must_equal ['a', ' "b', 'c"']
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
it "reads a stray quote in an unquoted field as data, without taking in the next line" do
|
|
566
|
+
skip "Observation: the quotes in a row are counted, so a stray quote leaves them unbalanced and the next line is taken into the row; unspecified since 0.11.4, :double since 0.12.5"
|
|
567
|
+
_(DSV.read("12\" pizza,9.99\nnext,row\n", as_array: true)).must_equal [['12" pizza', '9.99'], ['next', 'row']]
|
|
568
|
+
_(DSV.read("12\" pizza,9.99\nnext,row\n", as_array: true, quote: :double)).must_equal [['12" pizza', '9.99'], ['next', 'row']]
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
it "raises UnterminatedQuote on a quoted field which does not close" do
|
|
572
|
+
skip "Observation: a quoted field which does not close is dropped silently, with the rest of its row"
|
|
573
|
+
_{DSV.read("\"abc,d\n")}.must_raise DSV::UnterminatedQuote
|
|
574
|
+
_{DSV.read("\"ab\"c,d\n")}.must_raise DSV::UnterminatedQuote
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
|
|
551
578
|
describe "#write" do
|
|
552
579
|
it "writes each row in column order, double-quoted by default" do
|
|
553
580
|
output = written(columns: [:a, :b]){|csv| csv.rows = [{'a' => 1, 'b' => 2}]; csv.write}
|