1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Extract gemspec files to each gem directories

Since extension libraries can not be built in the source directory,
rubygems warns gems have extension libraries as the extensions are not
built.  To order to suppress this warnings, extract such gemspec files
under each gem directories instead of the common `specifications`
directory.
This commit is contained in:
Nobuyoshi Nakada 2022-07-13 17:47:36 +09:00
parent 8c74eaa08d
commit e1a4e44f14
Notes: git 2022-07-14 09:00:40 +09:00

View file

@ -11,10 +11,12 @@ def Gem.unpack(file, dir = nil, spec_dir = nil)
target = spec.full_name
target = File.join(dir, target) if dir
pkg.extract_files target
FileUtils.mkdir_p(spec_dir ||= target)
spec_file = File.join(spec_dir, "#{spec.name}-#{spec.version}.gemspec")
open(spec_file, 'wb') do |f|
f.print spec.to_ruby
if spec.extensions.empty?
spec_dir ||= target
else
spec_dir = target
end
FileUtils.mkdir_p(spec_dir)
File.binwrite(File.join(spec_dir, "#{spec.name}-#{spec.version}.gemspec"), spec.to_ruby)
puts "Unpacked #{file}"
end