smarter_csv 1.17.2 → 1.17.4
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.md +243 -61
- data/CONTRIBUTORS.md +2 -1
- data/README.md +5 -2
- data/UPGRADING.md +251 -0
- data/docs/.nojekyll +0 -0
- data/docs/upgrade_path.json +175 -0
- data/docs/upgrade_wizard.html +502 -0
- data/ext/smarter_csv/smarter_csv.c +176 -309
- data/lib/smarter_csv/parser.rb +4 -2
- data/lib/smarter_csv/reader.rb +18 -6
- data/lib/smarter_csv/version.rb +1 -1
- data/smarter_csv.gemspec +7 -5
- metadata +8 -2
data/lib/smarter_csv/parser.rb
CHANGED
|
@@ -195,8 +195,10 @@ module SmarterCSV
|
|
|
195
195
|
return [nil, n] if all_blank
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
-
#
|
|
199
|
-
|
|
198
|
+
# In-place strip! — allocation-free when there's no surrounding whitespace
|
|
199
|
+
# (matches the sister site in parse_csv_line_ruby; completes the
|
|
200
|
+
# "strip -> strip!" sweep documented in the 1.17.0 commit notes).
|
|
201
|
+
fields.each(&:strip!) if strip
|
|
200
202
|
|
|
201
203
|
remove_empty = options[:remove_empty_values]
|
|
202
204
|
hash = {}
|
data/lib/smarter_csv/reader.rb
CHANGED
|
@@ -32,13 +32,14 @@ module SmarterCSV
|
|
|
32
32
|
# rubocop:disable Naming/MethodName
|
|
33
33
|
def headerA
|
|
34
34
|
record_warning(type: :deprecation, code: :header_a_method) do
|
|
35
|
-
"
|
|
35
|
+
"Deprecation Warning: 'headerA' will be removed in future versions. Use 'headers'"
|
|
36
36
|
end
|
|
37
37
|
@headerA
|
|
38
38
|
end
|
|
39
39
|
# rubocop:enable Naming/MethodName
|
|
40
40
|
|
|
41
|
-
# first parameter:
|
|
41
|
+
# first parameter: a path (String or Pathname) to open, or an already-open readable IO
|
|
42
|
+
# (anything responding to #gets — File, StringIO, Tempfile, Zlib::GzipReader, pipes, ...)
|
|
42
43
|
def initialize(input, given_options = {})
|
|
43
44
|
@input = input
|
|
44
45
|
@has_rails = !!defined?(Rails)
|
|
@@ -123,7 +124,14 @@ module SmarterCSV
|
|
|
123
124
|
@verbose = options[:verbose]
|
|
124
125
|
|
|
125
126
|
begin
|
|
126
|
-
|
|
127
|
+
# Decide whether `input` is an already-open, readable stream or a path we must open.
|
|
128
|
+
# The reader reads lines via #gets (see file_io.rb and PeekableIO), so a public #gets
|
|
129
|
+
# is exactly what we need: real IOs (File, StringIO, Tempfile, Zlib::GzipReader, pipes,
|
|
130
|
+
# custom non-seekable streams) expose it, while path-like inputs (String, Pathname) do
|
|
131
|
+
# not — their only #gets is the private Kernel#gets. 1.17.0 narrowed this to
|
|
132
|
+
# input.is_a?(String), which sent Pathname down the IO branch and then called its
|
|
133
|
+
# private Kernel#gets, raising "private method 'gets' called" (issue #337).
|
|
134
|
+
fh = input.respond_to?(:gets) ? input : File.open(input, "r:#{options[:file_encoding]}")
|
|
127
135
|
|
|
128
136
|
# Rewindable inputs (File, Tempfile, StringIO, Zlib::GzipReader, ...) use
|
|
129
137
|
# native rewind for auto-detection — no wrapper overhead in the hot loop.
|
|
@@ -272,10 +280,14 @@ module SmarterCSV
|
|
|
272
280
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) if on_start || on_complete
|
|
273
281
|
|
|
274
282
|
if on_start
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
283
|
+
# Same path-vs-IO distinction as the File.open above: an already-open IO responds
|
|
284
|
+
# to #gets and we can't know its on-disk size, so we report its class name. A
|
|
285
|
+
# path-like input (String, or a Pathname via #to_path) gets its path and file size.
|
|
286
|
+
input_meta = if @input.respond_to?(:gets)
|
|
278
287
|
{ input: @input.class.name, file_size: nil }
|
|
288
|
+
else
|
|
289
|
+
path = @input.respond_to?(:to_path) ? @input.to_path : @input
|
|
290
|
+
{ input: path, file_size: (File.size(path) rescue nil) }
|
|
279
291
|
end
|
|
280
292
|
on_start.call(input_meta.merge(col_sep: options[:col_sep], row_sep: options[:row_sep]))
|
|
281
293
|
end
|
data/lib/smarter_csv/version.rb
CHANGED
data/smarter_csv.gemspec
CHANGED
|
@@ -30,11 +30,13 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.homepage = "https://github.com/tilo/smarter_csv"
|
|
31
31
|
spec.license = 'MIT'
|
|
32
32
|
|
|
33
|
-
spec.metadata["homepage_uri"]
|
|
34
|
-
spec.metadata["source_code_uri"]
|
|
35
|
-
spec.metadata["changelog_uri"]
|
|
36
|
-
spec.metadata["documentation_uri"]
|
|
37
|
-
spec.metadata["bug_tracker_uri"]
|
|
33
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
34
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
35
|
+
spec.metadata["changelog_uri"] = "https://github.com/tilo/smarter_csv/blob/main/CHANGELOG.md"
|
|
36
|
+
spec.metadata["documentation_uri"] = "https://github.com/tilo/smarter_csv/tree/main/docs"
|
|
37
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/tilo/smarter_csv/issues"
|
|
38
|
+
spec.metadata["upgrade_uri"] = "https://github.com/tilo/smarter_csv/blob/main/UPGRADING.md"
|
|
39
|
+
spec.metadata["upgrade_wizard_uri"] = "https://tilo.github.io/smarter_csv/upgrade_wizard.html"
|
|
38
40
|
|
|
39
41
|
spec.required_ruby_version = ">= 2.6.0"
|
|
40
42
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smarter_csv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.17.
|
|
4
|
+
version: 1.17.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tilo Sloboda
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-06-03 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: |
|
|
13
13
|
SmarterCSV is a high-performance CSV reader and writer for Ruby focused on
|
|
@@ -39,6 +39,8 @@ files:
|
|
|
39
39
|
- LICENSE.txt
|
|
40
40
|
- README.md
|
|
41
41
|
- Rakefile
|
|
42
|
+
- UPGRADING.md
|
|
43
|
+
- docs/.nojekyll
|
|
42
44
|
- docs/_introduction.md
|
|
43
45
|
- docs/bad_row_quarantine.md
|
|
44
46
|
- docs/basic_read_api.md
|
|
@@ -63,6 +65,8 @@ files:
|
|
|
63
65
|
- docs/releases/1.17.0/performance_notes.md
|
|
64
66
|
- docs/row_col_sep.md
|
|
65
67
|
- docs/ruby_csv_pitfalls.md
|
|
68
|
+
- docs/upgrade_path.json
|
|
69
|
+
- docs/upgrade_wizard.html
|
|
66
70
|
- docs/value_converters.md
|
|
67
71
|
- docs/warnings.md
|
|
68
72
|
- ext/smarter_csv/extconf.rb
|
|
@@ -101,6 +105,8 @@ metadata:
|
|
|
101
105
|
changelog_uri: https://github.com/tilo/smarter_csv/blob/main/CHANGELOG.md
|
|
102
106
|
documentation_uri: https://github.com/tilo/smarter_csv/tree/main/docs
|
|
103
107
|
bug_tracker_uri: https://github.com/tilo/smarter_csv/issues
|
|
108
|
+
upgrade_uri: https://github.com/tilo/smarter_csv/blob/main/UPGRADING.md
|
|
109
|
+
upgrade_wizard_uri: https://tilo.github.io/smarter_csv/upgrade_wizard.html
|
|
104
110
|
rdoc_options: []
|
|
105
111
|
require_paths:
|
|
106
112
|
- lib
|