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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6c8309ce7e75acd45ed55995d9c1ef8f04f1c6e945e56e80cb60d1fe4b7fa2a
4
- data.tar.gz: 2f6a5693d250797bf9e9ce69f2d06c2fd144e5722c7f3e7996c0f4029b71fdea
3
+ metadata.gz: 7322674ac0843543bf2f813312290dd2c4d460c7c3d0e8e8d604ccfcb680a196
4
+ data.tar.gz: 866e0a95d7854265444854111c0f1b61ed5e0faf9eb1f55ba20061f60fe52447
5
5
  SHA512:
6
- metadata.gz: c91f3fd66f79475ec7c617f47545378a08af49e3a78e7b52b684496b3ab6cb22205e2c26a5c7cd025ca26956ac8730685e2a4344ce7505ea4e46ef737ef0d7e5
7
- data.tar.gz: 3b2c669417438150a4fdfe421358e75362148ac7fa4fe8be1579c79b4c0f7f862283a2797dbef5bd02949cf9218daa61cdc194c0ca84844f443d39242e937245
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
@@ -2,5 +2,5 @@
2
2
  # DSV::VERSION
3
3
 
4
4
  class DSV
5
- VERSION = '0.12.5'
5
+ VERSION = '0.12.6'
6
6
  end
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}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5
4
+ version: 0.12.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran