csv 3.2.6 → 3.2.7
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/NEWS.md +44 -0
- data/doc/csv/options/parsing/liberal_parsing.rdoc +21 -2
- data/doc/csv/recipes/parsing.rdoc +1 -1
- data/lib/csv/parser.rb +4 -3
- data/lib/csv/row.rb +1 -1
- data/lib/csv/version.rb +1 -1
- data/lib/csv.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cc7b1ce29466412d00abcdb6afe594aa953f4b88367086398a3376484ca3344
|
4
|
+
data.tar.gz: b8112d963f92496cc775996c4e65d5b585601210fc03a4bc86eb4bf3c20e5f7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c29b38c150c691b52d0be24ab3dcdf32c430f2870de3ae4b26e704368caead83b27a581324a73515a85df8dc9571ab9f5fef1e8aa16a78f2ebfe3981a036063
|
7
|
+
data.tar.gz: 40cc68cb5a5eae059c3924e21e4fb53ae19e3c129f4b57e2bdcab35798742616daee93cf4bf9998de5333e03b01cc7b08a11da9700f04913a45f80741542d8f5
|
data/NEWS.md
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.2.7 - 2023-06-26
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* Removed an unused internal variable.
|
8
|
+
[GH-273](https://github.com/ruby/csv/issues/273)
|
9
|
+
[Patch by Mau Magnaguagno]
|
10
|
+
|
11
|
+
* Changed to use `https://` instead of `http://` in documents.
|
12
|
+
[GH-274](https://github.com/ruby/csv/issues/274)
|
13
|
+
[Patch by Vivek Bharath Akupatni]
|
14
|
+
|
15
|
+
* Added prefix to a helper module in test.
|
16
|
+
[GH-278](https://github.com/ruby/csv/issues/278)
|
17
|
+
[Patch by Luke Gruber]
|
18
|
+
|
19
|
+
* Added a documentation for `liberal_parsing: {backslash_quotes: true}`.
|
20
|
+
[GH-280](https://github.com/ruby/csv/issues/280)
|
21
|
+
[Patch by Mark Schneider]
|
22
|
+
|
23
|
+
### Fixes
|
24
|
+
|
25
|
+
* Fixed a wrong execution result in documents.
|
26
|
+
[GH-276](https://github.com/ruby/csv/issues/276)
|
27
|
+
[Patch by Yuki Tsujimoto]
|
28
|
+
|
29
|
+
* Fixed a bug that the same line is used multiple times.
|
30
|
+
[GH-279](https://github.com/ruby/csv/issues/279)
|
31
|
+
[Reported by Gabriel Nagy]
|
32
|
+
|
33
|
+
### Thanks
|
34
|
+
|
35
|
+
* Mau Magnaguagno
|
36
|
+
|
37
|
+
* Vivek Bharath Akupatni
|
38
|
+
|
39
|
+
* Yuki Tsujimoto
|
40
|
+
|
41
|
+
* Luke Gruber
|
42
|
+
|
43
|
+
* Mark Schneider
|
44
|
+
|
45
|
+
* Gabriel Nagy
|
46
|
+
|
3
47
|
## 3.2.6 - 2022-12-08
|
4
48
|
|
5
49
|
### Improvements
|
@@ -1,13 +1,13 @@
|
|
1
1
|
====== Option +liberal_parsing+
|
2
2
|
|
3
|
-
Specifies the boolean value that determines whether
|
3
|
+
Specifies the boolean or hash value that determines whether
|
4
4
|
CSV will attempt to parse input not conformant with RFC 4180,
|
5
5
|
such as double quotes in unquoted fields.
|
6
6
|
|
7
7
|
Default value:
|
8
8
|
CSV::DEFAULT_OPTIONS.fetch(:liberal_parsing) # => false
|
9
9
|
|
10
|
-
For
|
10
|
+
For the next two examples:
|
11
11
|
str = 'is,this "three, or four",fields'
|
12
12
|
|
13
13
|
Without +liberal_parsing+:
|
@@ -17,3 +17,22 @@ Without +liberal_parsing+:
|
|
17
17
|
With +liberal_parsing+:
|
18
18
|
ary = CSV.parse_line(str, liberal_parsing: true)
|
19
19
|
ary # => ["is", "this \"three", " or four\"", "fields"]
|
20
|
+
|
21
|
+
Use the +backslash_quote+ sub-option to parse values that use
|
22
|
+
a backslash to escape a double-quote character. This
|
23
|
+
causes the parser to treat <code>\"</code> as if it were
|
24
|
+
<code>""</code>.
|
25
|
+
|
26
|
+
For the next two examples:
|
27
|
+
str = 'Show,"Harry \"Handcuff\" Houdini, the one and only","Tampa Theater"'
|
28
|
+
|
29
|
+
With +liberal_parsing+, but without the +backslash_quote+ sub-option:
|
30
|
+
# Incorrect interpretation of backslash; incorrectly interprets the quoted comma as a field separator.
|
31
|
+
ary = CSV.parse_line(str, liberal_parsing: true)
|
32
|
+
ary # => ["Show", "\"Harry \\\"Handcuff\\\" Houdini", " the one and only\"", "Tampa Theater"]
|
33
|
+
puts ary[1] # => "Harry \"Handcuff\" Houdini
|
34
|
+
|
35
|
+
With +liberal_parsing+ and its +backslash_quote+ sub-option:
|
36
|
+
ary = CSV.parse_line(str, liberal_parsing: { backslash_quote: true })
|
37
|
+
ary # => ["Show", "Harry \"Handcuff\" Houdini, the one and only", "Tampa Theater"]
|
38
|
+
puts ary[1] # => Harry "Handcuff" Houdini, the one and only
|
@@ -520,7 +520,7 @@ Apply multiple header converters by defining and registering a custom header con
|
|
520
520
|
To capture unconverted field values, use option +:unconverted_fields+:
|
521
521
|
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
522
522
|
parsed = CSV.parse(source, converters: :integer, unconverted_fields: true)
|
523
|
-
parsed # => [["
|
523
|
+
parsed # => [["Name", "Value"], ["foo", 0], ["bar", 1], ["baz", 2]]
|
524
524
|
parsed.each {|row| p row.unconverted_fields }
|
525
525
|
Output:
|
526
526
|
["Name", "Value"]
|
data/lib/csv/parser.rb
CHANGED
@@ -101,7 +101,7 @@ class CSV
|
|
101
101
|
position = @scanner.pos
|
102
102
|
offset = 0
|
103
103
|
n_row_separator_chars = row_separator.size
|
104
|
-
# trace(__method__, :start,
|
104
|
+
# trace(__method__, :start, input)
|
105
105
|
while true
|
106
106
|
input.each_line(row_separator) do |line|
|
107
107
|
@scanner.pos += line.bytesize
|
@@ -157,6 +157,7 @@ class CSV
|
|
157
157
|
# trace(__method__, pattern, :done, :last, value) if @last_scanner
|
158
158
|
return value if @last_scanner
|
159
159
|
|
160
|
+
# trace(__method__, pattern, :done, :nil) if value.nil?
|
160
161
|
return nil if value.nil?
|
161
162
|
while @scanner.eos? and read_chunk and (sub_value = @scanner.scan(pattern))
|
162
163
|
# trace(__method__, pattern, :sub, sub_value)
|
@@ -200,7 +201,8 @@ class CSV
|
|
200
201
|
# trace(__method__, :rescan, start, buffer)
|
201
202
|
string = @scanner.string
|
202
203
|
if scanner == @scanner
|
203
|
-
keep = string.byteslice(start,
|
204
|
+
keep = string.byteslice(start,
|
205
|
+
string.bytesize - @scanner.pos - start)
|
204
206
|
else
|
205
207
|
keep = string
|
206
208
|
end
|
@@ -485,7 +487,6 @@ class CSV
|
|
485
487
|
message = ":quote_char has to be nil or a single character String"
|
486
488
|
raise ArgumentError, message
|
487
489
|
end
|
488
|
-
@double_quote_character = @quote_character * 2
|
489
490
|
@escaped_quote_character = Regexp.escape(@quote_character)
|
490
491
|
@escaped_quote = Regexp.new(@escaped_quote_character)
|
491
492
|
end
|
data/lib/csv/row.rb
CHANGED
@@ -703,7 +703,7 @@ class CSV
|
|
703
703
|
# by +index_or_header+ and +specifiers+.
|
704
704
|
#
|
705
705
|
# The nested objects may be instances of various classes.
|
706
|
-
# See {Dig Methods}[
|
706
|
+
# See {Dig Methods}[rdoc-ref:dig_methods.rdoc].
|
707
707
|
#
|
708
708
|
# Examples:
|
709
709
|
# source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
|
data/lib/csv/version.rb
CHANGED
data/lib/csv.rb
CHANGED
@@ -70,7 +70,7 @@
|
|
70
70
|
# == What is CSV, really?
|
71
71
|
#
|
72
72
|
# CSV maintains a pretty strict definition of CSV taken directly from
|
73
|
-
# {the RFC}[
|
73
|
+
# {the RFC}[https://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
|
74
74
|
# place and that is to make using this library easier. CSV will parse all valid
|
75
75
|
# CSV.
|
76
76
|
#
|
@@ -1144,7 +1144,7 @@ class CSV
|
|
1144
1144
|
# File.read('t.csv') # => "Name,Value\nFOO,0\nBAR,-1\nBAZ,-2\n"
|
1145
1145
|
#
|
1146
1146
|
# When neither +in_string_or_io+ nor +out_string_or_io+ given,
|
1147
|
-
# parses from {ARGF}[
|
1147
|
+
# parses from {ARGF}[rdoc-ref:ARGF]
|
1148
1148
|
# and generates to STDOUT.
|
1149
1149
|
#
|
1150
1150
|
# Without headers:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Edward Gray II
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
148
|
+
rubygems_version: 3.5.0.dev
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: CSV Reading and Writing
|