dsv.rb 0.16.2 → 0.16.3
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 +9 -0
- data/lib/DSV/Error.rb +2 -0
- data/lib/DSV/File.rb +2 -0
- data/lib/DSV/String.rb +2 -0
- data/lib/DSV/UnexpectedRow.rb +2 -0
- data/lib/DSV/UnquotedField.rb +2 -0
- data/lib/DSV/UnterminatedQuote.rb +2 -0
- data/lib/DSV/VERSION.rb +3 -1
- data/lib/dsv.rb +2 -0
- data/test/dsv_test.rb +21 -0
- data/test/helper.rb +1 -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: ead63c8e2d5d5f158043d38190a3bb2615a4c33036b9af7a3ae09f120908e18b
|
|
4
|
+
data.tar.gz: 76bb63eaead63387ea355954c0a4c4e428127776c848df8bcad64014726b0f75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be299164027f60f9f7bb17b0ec4a4da5a4ca35bcdf16241e4e740740857661da2523269ac8692b330163ed3cc30a8af981f7cd1fcb19f37e168f77cf9319f06a
|
|
7
|
+
data.tar.gz: 7089004ef941f46c946a5c79759fe0362a42c946c31136bd740bb35ad9319ff2d72df47b5f363614d7dbae4cc723a54a75becd9401bfbfa3bc29d2fd9fd14579
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# dsv/CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20261128
|
|
4
|
+
|
|
5
|
+
0.16.3: ~ DSV: Its String literals are frozen, so as reading makes half as many objects.
|
|
6
|
+
|
|
7
|
+
1. ~ DSV, DSV::File, DSV::String, DSV::Error, DSV::UnexpectedRow, DSV::UnquotedField, DSV::UnterminatedQuote, DSV::VERSION: Each file declares frozen_string_literal: true. A literal had been a new String each time it was reached, which in reading was several times for every quoted field.
|
|
8
|
+
2. ~ test/dsv_test.rb: The default row separator and mode are tested to be frozen, and quoted fields to be read without a new copy of the quote character each time it is used.
|
|
9
|
+
3. ~ test/helper.rb: + require 'objspace'
|
|
10
|
+
4. ~ DSV::VERSION: /0.16.2/0.16.3/
|
|
11
|
+
|
|
3
12
|
## 20261127
|
|
4
13
|
|
|
5
14
|
0.16.2: ~ DSV#read, ~ DSV#write: The columns selected are flattened once, not for every row.
|
data/lib/DSV/Error.rb
CHANGED
data/lib/DSV/File.rb
CHANGED
data/lib/DSV/String.rb
CHANGED
data/lib/DSV/UnexpectedRow.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# DSV/UnexpectedRow.rb
|
|
2
2
|
# DSV::UnexpectedRow
|
|
3
3
|
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
4
6
|
class DSV
|
|
5
7
|
# A row which contradicts its declared quote mode; mode is the mode in force, and line the one on which the row began, given by the reader once it knows it.
|
|
6
8
|
class UnexpectedRow < Error
|
data/lib/DSV/UnquotedField.rb
CHANGED
data/lib/DSV/VERSION.rb
CHANGED
data/lib/dsv.rb
CHANGED
data/test/dsv_test.rb
CHANGED
|
@@ -396,6 +396,12 @@ describe DSV do
|
|
|
396
396
|
_(DSV.new(DATA).quote).must_be_nil
|
|
397
397
|
end
|
|
398
398
|
|
|
399
|
+
it "gives its own defaults frozen" do
|
|
400
|
+
csv = DSV.new("a,b\n")
|
|
401
|
+
_(csv.row_separator).must_be :frozen?
|
|
402
|
+
_(csv.mode).must_be :frozen?
|
|
403
|
+
end
|
|
404
|
+
|
|
399
405
|
it "has its interface public and its internals private" do
|
|
400
406
|
csv = DSV.new(DATA, headers: true)
|
|
401
407
|
[:close, :read, :read_header, :parse, :columns, :columns=, :repeated_names, :parse_row, :write, :write_header, :write_row, :each, :attributes, :attributes=, :header_row?, :first_row, :to_a].each{|name| _(csv.public_methods).must_include name}
|
|
@@ -744,6 +750,21 @@ describe DSV do
|
|
|
744
750
|
csv.quote = :single
|
|
745
751
|
_(csv.read).must_equal [{0 => 'a', 1 => 'b'}]
|
|
746
752
|
end
|
|
753
|
+
|
|
754
|
+
it "reads quoted fields without making a new copy of the quote character each time it is used" do
|
|
755
|
+
csv = DSV.new(%Q{"a","b"\n"c","d"\n})
|
|
756
|
+
quotes = []
|
|
757
|
+
GC.disable
|
|
758
|
+
begin
|
|
759
|
+
ObjectSpace.trace_object_allocations do
|
|
760
|
+
csv.read
|
|
761
|
+
ObjectSpace.each_object(::String){|s| quotes << s if ['"', '""'].include?(s) && ObjectSpace.allocation_sourcefile(s).to_s.end_with?('dsv.rb')}
|
|
762
|
+
end
|
|
763
|
+
ensure
|
|
764
|
+
GC.enable
|
|
765
|
+
end
|
|
766
|
+
_(quotes).must_be_empty
|
|
767
|
+
end
|
|
747
768
|
end
|
|
748
769
|
|
|
749
770
|
# Input which is not RFC 4180, read to the default rule: a quote is structure only where it opens a field, and a field it opens which does not close raises UnterminatedQuote.
|
data/test/helper.rb
CHANGED