From a772f447ddd0c7593190033557ef435dc05639ce Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 4 Jan 2024 09:51:58 +0000 Subject: [PATCH] Fix version extraction to work with non ASCII characters with any `LANG` d9fe72afe9 introduced a non-ASCII character (U+2014) in comment but Regex match failed with non UTF-8 locale. This commit fixes it by specifying encoding explicitly. --- net-smtp.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net-smtp.gemspec b/net-smtp.gemspec index b19844f..07d9703 100644 --- a/net-smtp.gemspec +++ b/net-smtp.gemspec @@ -2,7 +2,7 @@ name = File.basename(__FILE__, ".gemspec") version = ["lib", Array.new(name.count("-"), "..").join("/")].find do |dir| - break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line| + break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb"), :encoding => "UTF-8") do |line| /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1 end rescue nil end