1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/gem-unpack.rb
Nobuyoshi Nakada 91f831ac17
Extract gemspec to versioned file
Not to be overwritten by test-bundler-prepare.  gem files often
contain useless gemspec files which have not been processed.
2020-12-07 23:47:37 +09:00

18 lines
464 B
Ruby

require 'rubygems'
require 'rubygems/package'
# This library is used by "make extract-gems" to
# unpack bundled gem files.
def Gem.unpack(file, dir = nil)
pkg = Gem::Package.new(file)
spec = pkg.spec
target = spec.full_name
target = File.join(dir, target) if dir
pkg.extract_files target
spec_file = File.join(target, "#{spec.name}-#{spec.version}.gemspec")
open(spec_file, 'wb') do |f|
f.print spec.to_ruby
end
puts "Unpacked #{file}"
end