Skip to content

Commit

Permalink
Support file listing with IO.poepn style
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Feb 28, 2024
1 parent fe0b704 commit 75a4aa2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tool/rbinstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -958,17 +958,20 @@ def ensure_writable_dir(dir)
def load_gemspec(file, base = nil)
file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-")

files = []
Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
case File.basename(n); when ".", ".."; next; end
next if File.directory?(File.join(base, n))
files << n.dump
end if base
code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\([^\)]*\)/m) do
files = []
if base
Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
case File.basename(n); when ".", ".."; next; end
next if File.directory?(File.join(base, n))
files << n.dump
end
end
"[" + files.join(", ") + "]"
end
code.gsub!(/IO\.popen\(.*git.*?\)/) do
"[" + files.join(", ") + "].each"
end

spec = eval(code, binding, file)
unless Gem::Specification === spec
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
Expand Down

0 comments on commit 75a4aa2

Please sign in to comment.