2020-12-08 04:38:25 -05:00
|
|
|
require 'fileutils'
|
2015-01-15 23:52:59 -05:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/package'
|
|
|
|
|
2016-07-02 17:01:04 -04:00
|
|
|
# This library is used by "make extract-gems" to
|
|
|
|
# unpack bundled gem files.
|
|
|
|
|
2022-04-06 09:57:01 -04:00
|
|
|
def Gem.unpack(file, dir = nil, spec_dir = nil)
|
2015-01-15 23:52:59 -05:00
|
|
|
pkg = Gem::Package.new(file)
|
|
|
|
spec = pkg.spec
|
|
|
|
target = spec.full_name
|
|
|
|
target = File.join(dir, target) if dir
|
|
|
|
pkg.extract_files target
|
2022-07-13 04:47:36 -04:00
|
|
|
if spec.extensions.empty?
|
|
|
|
spec_dir ||= target
|
|
|
|
else
|
|
|
|
spec_dir = target
|
2015-01-15 23:52:59 -05:00
|
|
|
end
|
2022-07-13 04:47:36 -04:00
|
|
|
FileUtils.mkdir_p(spec_dir)
|
|
|
|
File.binwrite(File.join(spec_dir, "#{spec.name}-#{spec.version}.gemspec"), spec.to_ruby)
|
2015-01-15 23:52:59 -05:00
|
|
|
puts "Unpacked #{file}"
|
|
|
|
end
|