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

17 lines
421 B
Ruby
Raw Normal View History

require 'rubygems'
require 'rubygems/package'
def Gem.unpack(file, dir = nil)
pkg = Gem::Package.new(file)
pkg.security_policy = Gem::Security::LowSecurity
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}.gemspec")
open(spec_file, 'wb') do |f|
f.print spec.to_ruby
end
puts "Unpacked #{file}"
end