csv 3.3.2 → 3.3.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/NEWS.md +25 -0
- data/bin/csv-filter +59 -0
- data/lib/csv/parser.rb +15 -5
- data/lib/csv/version.rb +1 -1
- data/lib/csv.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b09d2eaa0c8e6c8c385fa6f958d93d893ee7c3441cc83248d07562cd719d960
|
4
|
+
data.tar.gz: 7e2aff2545b8bbeaefd4adb73627e7345bec284b18d431f3ab41f5a136f479a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88525c73bd61ae40b2fe4314a402210acc2ad4993def484e7531d6356d1652f80b2b5a1f72be1f4b4a38350d4c25d00ac43b3a8b1b41817b0c95bc2df8f5c082
|
7
|
+
data.tar.gz: 28322a68f915cee37aebbcd2fbaee39293d289760c878f3b6bcfe237a9247fd319368d1c54d9170f25929625b71c89475b016ccbdb80afc88a3d0926784b6a7e
|
data/NEWS.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
+
## 3.3.3 - 2025-03-20
|
4
|
+
|
5
|
+
### Improvements
|
6
|
+
|
7
|
+
* `csv-filter`: Add an experimental command line tool to filter a CSV.
|
8
|
+
* Patch by Burdette Lamar
|
9
|
+
|
10
|
+
### Fixes
|
11
|
+
|
12
|
+
* Fixed wrong EOF detection for `ARGF`
|
13
|
+
* GH-328
|
14
|
+
* Reported by Takeshi Nishimatsu
|
15
|
+
|
16
|
+
* Fixed a regression bug that `CSV.open` rejects integer mode.
|
17
|
+
* GH-336
|
18
|
+
* Reported by Dave Burgess
|
19
|
+
|
20
|
+
### Thanks
|
21
|
+
|
22
|
+
* Takeshi Nishimatsu
|
23
|
+
|
24
|
+
* Burdette Lamar
|
25
|
+
|
26
|
+
* Dave Burgess
|
27
|
+
|
3
28
|
## 3.3.2 - 2024-12-21
|
4
29
|
|
5
30
|
### Fixes
|
data/bin/csv-filter
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'csv'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
parser = OptionParser.new
|
9
|
+
|
10
|
+
parser.version = CSV::VERSION
|
11
|
+
parser.banner = <<-BANNER
|
12
|
+
Usage: #{parser.program_name} [options]
|
13
|
+
|
14
|
+
Reads and parses the CSV text content of the standard input per the given input options.
|
15
|
+
From that content, generates CSV text per the given output options
|
16
|
+
and writes that text to the standard output.
|
17
|
+
BANNER
|
18
|
+
|
19
|
+
|
20
|
+
parser.on('--input-col-sep=SEPARATOR',
|
21
|
+
'Input column separator string.') do |value|
|
22
|
+
options[:input_col_sep] = value
|
23
|
+
end
|
24
|
+
|
25
|
+
parser.on('--input-quote-char=SEPARATOR',
|
26
|
+
'Input quote character.') do |value|
|
27
|
+
options[:input_quote_char] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
parser.on('--input-row-sep=SEPARATOR',
|
31
|
+
'Input row separator string.') do |value|
|
32
|
+
options[:input_row_sep] = value
|
33
|
+
end
|
34
|
+
|
35
|
+
parser.on('--output-col-sep=SEPARATOR',
|
36
|
+
'Output column separator string.') do |value|
|
37
|
+
options[:output_col_sep] = value
|
38
|
+
end
|
39
|
+
|
40
|
+
parser.on('--output-row-sep=SEPARATOR',
|
41
|
+
'Output row separator string.') do |value|
|
42
|
+
options[:output_row_sep] = value
|
43
|
+
end
|
44
|
+
|
45
|
+
parser.on('-r', '--row-sep=SEPARATOR',
|
46
|
+
'Row separator string.') do |value|
|
47
|
+
options[:row_sep] = value
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
parser.parse!
|
52
|
+
rescue OptionParser::InvalidOption
|
53
|
+
$stderr.puts($!.message)
|
54
|
+
$stderr.puts(parser)
|
55
|
+
exit(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
CSV.filter(**options) do |row|
|
59
|
+
end
|
data/lib/csv/parser.rb
CHANGED
@@ -18,6 +18,19 @@ class CSV
|
|
18
18
|
# into your Encoding.
|
19
19
|
#
|
20
20
|
|
21
|
+
class << self
|
22
|
+
ARGF_OBJECT_ID = ARGF.object_id
|
23
|
+
# Convenient method to check whether the give input reached EOF
|
24
|
+
# or not.
|
25
|
+
def eof?(input)
|
26
|
+
# We can't use input != ARGF in Ractor. Because ARGF isn't a
|
27
|
+
# shareable object.
|
28
|
+
input.object_id != ARGF_OBJECT_ID and
|
29
|
+
input.respond_to?(:eof) and
|
30
|
+
input.eof?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
21
34
|
# Raised when encoding is invalid.
|
22
35
|
class InvalidEncoding < StandardError
|
23
36
|
end
|
@@ -312,7 +325,7 @@ class CSV
|
|
312
325
|
raise InvalidEncoding unless chunk.valid_encoding?
|
313
326
|
# trace(__method__, :chunk, chunk)
|
314
327
|
@scanner = StringScanner.new(chunk)
|
315
|
-
if
|
328
|
+
if Parser.eof?(input)
|
316
329
|
@inputs.shift
|
317
330
|
@last_scanner = @inputs.empty?
|
318
331
|
end
|
@@ -869,10 +882,7 @@ class CSV
|
|
869
882
|
string = nil
|
870
883
|
if @samples.empty? and @input.is_a?(StringIO)
|
871
884
|
string = @input.read
|
872
|
-
elsif @samples.size == 1 and
|
873
|
-
@input != ARGF and
|
874
|
-
@input.respond_to?(:eof?) and
|
875
|
-
@input.eof?
|
885
|
+
elsif @samples.size == 1 and Parser.eof?(@input)
|
876
886
|
string = @samples[0]
|
877
887
|
end
|
878
888
|
if string
|
data/lib/csv/version.rb
CHANGED
data/lib/csv.rb
CHANGED
@@ -1976,7 +1976,7 @@ class CSV
|
|
1976
1976
|
return unless Encoding.default_external == Encoding::UTF_8
|
1977
1977
|
return if options.key?(:encoding)
|
1978
1978
|
return if options.key?(:external_encoding)
|
1979
|
-
return if mode.include?(":")
|
1979
|
+
return if mode.is_a?(String) and mode.include?(":")
|
1980
1980
|
file_opts[:encoding] = "bom|utf-8"
|
1981
1981
|
end
|
1982
1982
|
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Edward Gray II
|
8
8
|
- Kouhei Sutou
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2025-03-20 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: The CSV library provides a complete interface to CSV files and data.
|
15
14
|
It offers tools to enable you to read and write to and from Strings or IO objects,
|
@@ -17,7 +16,8 @@ description: The CSV library provides a complete interface to CSV files and data
|
|
17
16
|
email:
|
18
17
|
-
|
19
18
|
- kou@cozmixng.org
|
20
|
-
executables:
|
19
|
+
executables:
|
20
|
+
- csv-filter
|
21
21
|
extensions: []
|
22
22
|
extra_rdoc_files:
|
23
23
|
- LICENSE.txt
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- LICENSE.txt
|
32
32
|
- NEWS.md
|
33
33
|
- README.md
|
34
|
+
- bin/csv-filter
|
34
35
|
- doc/csv/arguments/io.rdoc
|
35
36
|
- doc/csv/options/common/col_sep.rdoc
|
36
37
|
- doc/csv/options/common/quote_char.rdoc
|
@@ -71,8 +72,8 @@ homepage: https://github.com/ruby/csv
|
|
71
72
|
licenses:
|
72
73
|
- Ruby
|
73
74
|
- BSD-2-Clause
|
74
|
-
metadata:
|
75
|
-
|
75
|
+
metadata:
|
76
|
+
changelog_uri: https://github.com/ruby/csv/releases/tag/v3.3.3
|
76
77
|
rdoc_options:
|
77
78
|
- "--main"
|
78
79
|
- README.md
|
@@ -89,8 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
- !ruby/object:Gem::Version
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
93
|
+
rubygems_version: 3.6.2
|
94
94
|
specification_version: 4
|
95
95
|
summary: CSV Reading and Writing
|
96
96
|
test_files: []
|