csv 3.2.6 → 3.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48581eef7d2903fa52d36b48a8c1596396a5957b166c99ea8dcfd14ffb0dc221
4
- data.tar.gz: fa6a5cdd9ade30c0a45f7974dcb43128d5e99cc7bf344e9e5b012993ad081ffe
3
+ metadata.gz: 6cc7b1ce29466412d00abcdb6afe594aa953f4b88367086398a3376484ca3344
4
+ data.tar.gz: b8112d963f92496cc775996c4e65d5b585601210fc03a4bc86eb4bf3c20e5f7d
5
5
  SHA512:
6
- metadata.gz: 00f55443919b4ece138c025818a440ed4a6d0bed64917bcb6f6e810e318f4738f9e129371434c8711173e818b5b58e1d4b2ac2987612617922fda74f03bd3a4b
7
- data.tar.gz: 0b83b3b64bf5287653054fa8ecfd4e345f5c41a2a0daedbdba355c4d034bc85c917cf87bd9ee1ede54475ec4e31caadaee54cc2553d529e9ba5b0bc1d5806ff0
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 examples in this section:
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 # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
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, line, input)
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, string.bytesize - 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}[https://docs.ruby-lang.org/en/master/dig_methods_rdoc.html].
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  class CSV
4
4
  # The version of the installed library.
5
- VERSION = "3.2.6"
5
+ VERSION = "3.2.7"
6
6
  end
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}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
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}[https://docs.ruby-lang.org/en/master/ARGF.html]
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.6
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: 2022-12-08 00:00:00.000000000 Z
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.4.0.dev
148
+ rubygems_version: 3.5.0.dev
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: CSV Reading and Writing