2020-12-08 12:38:25 +03:00
|
|
|
require 'fileutils'
|
2015-01-16 07:52:59 +03:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rubygems/package'
|
|
|
|
|
2016-07-03 00:01:04 +03:00
|
|
|
# This library is used by "make extract-gems" to
|
|
|
|
# unpack bundled gem files.
|
|
|
|
|
2015-01-16 07:52:59 +03:00
|
|
|
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
|
2020-12-07 17:47:37 +03:00
|
|
|
spec_file = File.join(target, "#{spec.name}-#{spec.version}.gemspec")
|
2015-01-16 07:52:59 +03:00
|
|
|
open(spec_file, 'wb') do |f|
|
|
|
|
f.print spec.to_ruby
|
|
|
|
end
|
|
|
|
puts "Unpacked #{file}"
|
|
|
|
end
|