aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Unit 193 <unit193@unit193.net>2021-11-01 22:50:31 -0400
committerLibravatar Unit 193 <unit193@unit193.net>2021-11-01 22:50:31 -0400
commit6763615ba21089291ecba9f414f44f0c5d7bf092 (patch)
tree3b2c34105ffffa0b6210a34530ce549dda8bbfbd
parent8273331581782f42f129950ccdd4e71498605da2 (diff)
downloadruby-roo-6763615ba21089291ecba9f414f44f0c5d7bf092.tar.bz2
ruby-roo-6763615ba21089291ecba9f414f44f0c5d7bf092.tar.xz
ruby-roo-6763615ba21089291ecba9f414f44f0c5d7bf092.tar.zst
d/p/ruby3.0_compatibility.patch: Grab two patches from upstream to fix compatibility with Ruby 3.0.
Closes: #996371
-rw-r--r--debian/patches/ruby3.0_compatibility.patch75
-rw-r--r--debian/patches/series1
2 files changed, 76 insertions, 0 deletions
diff --git a/debian/patches/ruby3.0_compatibility.patch b/debian/patches/ruby3.0_compatibility.patch
new file mode 100644
index 0000000..c35dc0b
--- /dev/null
+++ b/debian/patches/ruby3.0_compatibility.patch
@@ -0,0 +1,75 @@
+From: taichi <taichi730@gmail.com>
+Subject: Grab two patches from upstream to fix compatibility with Ruby 3.0.
+ [PATCH] fixed warnings caused by keyword argument change
+ [PATCH] adapted for obsoletion of URI.encode method
+
+Origin: upstream
+Bug-Debian: https://bugs.debian.org/996371
+
+---
+ lib/roo/csv.rb | 27 +++++++++++++++++++++++----
+ lib/roo/spreadsheet.rb | 10 ++++++++--
+ 2 files changed, 31 insertions(+), 6 deletions(-)
+
+--- a/lib/roo/csv.rb 2021-10-30 21:50:24.101318627 -0400
++++ b/lib/roo/csv.rb 2021-10-30 21:50:24.089318711 -0400
+@@ -90,17 +90,36 @@
+ def each_row(options, &block)
+ if uri?(filename)
+ each_row_using_tempdir(options, &block)
+- elsif is_stream?(filename_or_stream)
+- ::CSV.new(filename_or_stream, options).each(&block)
+ else
+- ::CSV.foreach(filename, options, &block)
++ csv_foreach(filename_or_stream, options, &block)
+ end
+ end
+
+ def each_row_using_tempdir(options, &block)
+ ::Dir.mktmpdir(Roo::TEMP_PREFIX, ENV["ROO_TMP"]) do |tmpdir|
+ tmp_filename = download_uri(filename, tmpdir)
+- ::CSV.foreach(tmp_filename, options, &block)
++ csv_foreach(tmp_filename, options, &block)
++ end
++ end
++
++ # From Ruby 2.5, options argument of CSV.new/CSV.foreach is a keyword argument.
++ # Before Ruby 2.5, that argument is a Hash.
++ # Therefore, this workaround can be removed if Ruby 2.3 and 2.4 are dropped.
++ if RUBY_VERSION >= '2.5.0'
++ def csv_foreach(path_or_io, options, &block)
++ if is_stream?(path_or_io)
++ ::CSV.new(path_or_io, **options).each(&block)
++ else
++ ::CSV.foreach(path_or_io, **options, &block)
++ end
++ end
++ else
++ def csv_foreach(path_or_io, options, &block)
++ if is_stream?(path_or_io)
++ ::CSV.new(path_or_io, options).each(&block)
++ else
++ ::CSV.foreach(path_or_io, options, &block)
++ end
+ end
+ end
+
+--- a/lib/roo/spreadsheet.rb 2021-10-30 21:50:24.101318627 -0400
++++ b/lib/roo/spreadsheet.rb 2021-10-30 21:50:24.089318711 -0400
+@@ -24,8 +24,14 @@
+ options[:file_warning] = :ignore
+ extension.tr('.', '').downcase.to_sym
+ else
+- res = ::File.extname((path =~ /\A#{::URI::DEFAULT_PARSER.make_regexp}\z/) ? ::URI.parse(::URI.encode(path)).path : path)
+- res.tr('.', '').downcase.to_sym
++ parsed_path =
++ if path =~ /\A#{::URI::DEFAULT_PARSER.make_regexp}\z/
++ # path is 7th match
++ Regexp.last_match[7]
++ else
++ path
++ end
++ ::File.extname(parsed_path).tr('.', '').downcase.to_sym
+ end
+ end
+ end
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..e2a6e04
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+ruby3.0_compatibility.patch