2015-01-16 07:52:59 +03:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/package'
|
|
|
|
|
|
|
|
def Gem.unpack(file, dir = nil)
|
2015-01-17 09:55:20 +03:00
|
|
|
policy = Gem::Security::LowSecurity
|
|
|
|
(policy = policy.dup).ui = Gem::SilentUI.new
|
2015-01-16 07:52:59 +03:00
|
|
|
pkg = Gem::Package.new(file)
|
2015-01-17 09:55:20 +03:00
|
|
|
pkg.security_policy = policy
|
2015-01-16 07:52:59 +03:00
|
|
|
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
|