csv 3.2.4 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +49 -0
- data/lib/csv/table.rb +1 -2
- data/lib/csv/version.rb +1 -1
- data/lib/csv.rb +49 -3
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48581eef7d2903fa52d36b48a8c1596396a5957b166c99ea8dcfd14ffb0dc221
|
4
|
+
data.tar.gz: fa6a5cdd9ade30c0a45f7974dcb43128d5e99cc7bf344e9e5b012993ad081ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00f55443919b4ece138c025818a440ed4a6d0bed64917bcb6f6e810e318f4738f9e129371434c8711173e818b5b58e1d4b2ac2987612617922fda74f03bd3a4b
|
7
|
+
data.tar.gz: 0b83b3b64bf5287653054fa8ecfd4e345f5c41a2a0daedbdba355c4d034bc85c917cf87bd9ee1ede54475ec4e31caadaee54cc2553d529e9ba5b0bc1d5806ff0
|
data/NEWS.md
CHANGED
@@ -1,5 +1,54 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.2.6 - 2022-12-08
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* `CSV#read` consumes the same lines with other methods like
|
8
|
+
`CSV#shift`.
|
9
|
+
[[GitHub#258](https://github.com/ruby/csv/issues/258)]
|
10
|
+
[Reported by Lhoussaine Ghallou]
|
11
|
+
|
12
|
+
* All `Enumerable` based methods consume the same lines with other
|
13
|
+
methods. This may have a performance penalty.
|
14
|
+
[[GitHub#260](https://github.com/ruby/csv/issues/260)]
|
15
|
+
[Reported by Lhoussaine Ghallou]
|
16
|
+
|
17
|
+
* Simplify some implementations.
|
18
|
+
[[GitHub#262](https://github.com/ruby/csv/pull/262)]
|
19
|
+
[[GitHub#263](https://github.com/ruby/csv/pull/263)]
|
20
|
+
[Patch by Mau Magnaguagno]
|
21
|
+
|
22
|
+
### Fixes
|
23
|
+
|
24
|
+
* Fixed `CSV.generate_lines` document.
|
25
|
+
[[GitHub#257](https://github.com/ruby/csv/pull/257)]
|
26
|
+
[Patch by Sampat Badhe]
|
27
|
+
|
28
|
+
### Thanks
|
29
|
+
|
30
|
+
* Sampat Badhe
|
31
|
+
|
32
|
+
* Lhoussaine Ghallou
|
33
|
+
|
34
|
+
* Mau Magnaguagno
|
35
|
+
|
36
|
+
## 3.2.5 - 2022-08-26
|
37
|
+
|
38
|
+
### Improvements
|
39
|
+
|
40
|
+
* Added `CSV.generate_lines`.
|
41
|
+
[[GitHub#255](https://github.com/ruby/csv/issues/255)]
|
42
|
+
[Reported by OKURA Masafumi]
|
43
|
+
[[GitHub#256](https://github.com/ruby/csv/pull/256)]
|
44
|
+
[Patch by Eriko Sugiyama]
|
45
|
+
|
46
|
+
### Thanks
|
47
|
+
|
48
|
+
* OKURA Masafumi
|
49
|
+
|
50
|
+
* Eriko Sugiyama
|
51
|
+
|
3
52
|
## 3.2.4 - 2022-08-22
|
4
53
|
|
5
54
|
### Improvements
|
data/lib/csv/table.rb
CHANGED
@@ -890,9 +890,8 @@ class CSV
|
|
890
890
|
if @mode == :row or @mode == :col_or_row # by index
|
891
891
|
@table.delete_if(&block)
|
892
892
|
else # by header
|
893
|
-
deleted = []
|
894
893
|
headers.each do |header|
|
895
|
-
|
894
|
+
delete(header) if yield([header, self[header]])
|
896
895
|
end
|
897
896
|
end
|
898
897
|
|
data/lib/csv/version.rb
CHANGED
data/lib/csv.rb
CHANGED
@@ -1005,7 +1005,7 @@ class CSV
|
|
1005
1005
|
def instance(data = $stdout, **options)
|
1006
1006
|
# create a _signature_ for this method call, data object and options
|
1007
1007
|
sig = [data.object_id] +
|
1008
|
-
options.values_at(*DEFAULT_OPTIONS.keys
|
1008
|
+
options.values_at(*DEFAULT_OPTIONS.keys)
|
1009
1009
|
|
1010
1010
|
# fetch or create the instance for this signature
|
1011
1011
|
@@instances ||= Hash.new
|
@@ -1202,7 +1202,7 @@ class CSV
|
|
1202
1202
|
# parse options for input, output, or both
|
1203
1203
|
in_options, out_options = Hash.new, {row_sep: InputRecordSeparator.value}
|
1204
1204
|
options.each do |key, value|
|
1205
|
-
case key
|
1205
|
+
case key
|
1206
1206
|
when /\Ain(?:put)?_(.+)\Z/
|
1207
1207
|
in_options[$1.to_sym] = value
|
1208
1208
|
when /\Aout(?:put)?_(.+)\Z/
|
@@ -1465,6 +1465,46 @@ class CSV
|
|
1465
1465
|
(new(str, **options) << row).string
|
1466
1466
|
end
|
1467
1467
|
|
1468
|
+
# :call-seq:
|
1469
|
+
# CSV.generate_lines(rows)
|
1470
|
+
# CSV.generate_lines(rows, **options)
|
1471
|
+
#
|
1472
|
+
# Returns the \String created by generating \CSV from
|
1473
|
+
# using the specified +options+.
|
1474
|
+
#
|
1475
|
+
# Argument +rows+ must be an \Array of row. Row is \Array of \String or \CSV::Row.
|
1476
|
+
#
|
1477
|
+
# Special options:
|
1478
|
+
# * Option <tt>:row_sep</tt> defaults to <tt>"\n"</tt> on Ruby 3.0 or later
|
1479
|
+
# and <tt>$INPUT_RECORD_SEPARATOR</tt> (<tt>$/</tt>) otherwise.:
|
1480
|
+
# $INPUT_RECORD_SEPARATOR # => "\n"
|
1481
|
+
# * This method accepts an additional option, <tt>:encoding</tt>, which sets the base
|
1482
|
+
# Encoding for the output. This method will try to guess your Encoding from
|
1483
|
+
# the first non-+nil+ field in +row+, if possible, but you may need to use
|
1484
|
+
# this parameter as a backup plan.
|
1485
|
+
#
|
1486
|
+
# For other +options+,
|
1487
|
+
# see {Options for Generating}[#class-CSV-label-Options+for+Generating].
|
1488
|
+
#
|
1489
|
+
# ---
|
1490
|
+
#
|
1491
|
+
# Returns the \String generated from an
|
1492
|
+
# CSV.generate_lines([['foo', '0'], ['bar', '1'], ['baz', '2']]) # => "foo,0\nbar,1\nbaz,2\n"
|
1493
|
+
#
|
1494
|
+
# ---
|
1495
|
+
#
|
1496
|
+
# Raises an exception
|
1497
|
+
# # Raises NoMethodError (undefined method `each' for :foo:Symbol)
|
1498
|
+
# CSV.generate_lines(:foo)
|
1499
|
+
#
|
1500
|
+
def generate_lines(rows, **options)
|
1501
|
+
self.generate(**options) do |csv|
|
1502
|
+
rows.each do |row|
|
1503
|
+
csv << row
|
1504
|
+
end
|
1505
|
+
end
|
1506
|
+
end
|
1507
|
+
|
1468
1508
|
#
|
1469
1509
|
# :call-seq:
|
1470
1510
|
# open(file_path, mode = "rb", **options ) -> new_csv
|
@@ -2511,7 +2551,13 @@ class CSV
|
|
2511
2551
|
# p row
|
2512
2552
|
# end
|
2513
2553
|
def each(&block)
|
2514
|
-
|
2554
|
+
return to_enum(__method__) unless block_given?
|
2555
|
+
begin
|
2556
|
+
while true
|
2557
|
+
yield(parser_enumerator.next)
|
2558
|
+
end
|
2559
|
+
rescue StopIteration
|
2560
|
+
end
|
2515
2561
|
end
|
2516
2562
|
|
2517
2563
|
# :call-seq:
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Edward Gray II
|
8
8
|
- Kouhei Sutou
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-08
|
12
|
+
date: 2022-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -71,7 +71,7 @@ description: The CSV library provides a complete interface to CSV files and data
|
|
71
71
|
It offers tools to enable you to read and write to and from Strings or IO objects,
|
72
72
|
as needed.
|
73
73
|
email:
|
74
|
-
-
|
74
|
+
-
|
75
75
|
- kou@cozmixng.org
|
76
76
|
executables: []
|
77
77
|
extensions: []
|
@@ -128,7 +128,7 @@ licenses:
|
|
128
128
|
- Ruby
|
129
129
|
- BSD-2-Clause
|
130
130
|
metadata: {}
|
131
|
-
post_install_message:
|
131
|
+
post_install_message:
|
132
132
|
rdoc_options:
|
133
133
|
- "--main"
|
134
134
|
- README.md
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubygems_version: 3.4.0.dev
|
149
|
-
signing_key:
|
149
|
+
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: CSV Reading and Writing
|
152
152
|
test_files: []
|