From 5894ea5954db119fc818bb7030ed56cf46830c6d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 7 Dec 2020 22:27:29 +0900 Subject: rbinstall.rb: fix the position to expand files As `spec.files` is used for `executables` and so on, the expanded list needs to be located at the same place. --- tool/rbinstall.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'tool') diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 97cde087c6..fcc41f2151 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -874,25 +874,25 @@ end def load_gemspec(file, expanded = false) file = File.realpath(file) code = File.read(file, encoding: "utf-8:-") - code.gsub!(/`git.*?`/m, '""') - code.gsub!(/%x\[git.*?\]/m, '""') + code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\(\"(?:\\.|[^\"])*\"\)/m) do + files = [] + if expanded + base = File.dirname(file) + Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n| + next if n.start_with?(".git") # git related files are useless + case File.basename(n); when ".", ".."; next; end + next if File.directory?(File.join(base, n)) + files << n.dump + end + end + "[" + files.join(", ") + "]" + end spec = eval(code, binding, file) unless Gem::Specification === spec raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)." end spec.loaded_from = file - # gather expanded bundled gem files - if expanded - base = File.dirname(file) - Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n| - next if n.start_with?(".git") # git related files are useless - case File.basename(n); when ".", ".."; next; end - next if File.directory?(File.join(base, n)) - spec.files << n - end - end - spec end -- cgit v1.2.3