lib/yard/cli/diff.rb in yard-0.8.5 vs lib/yard/cli/diff.rb in yard-0.8.5.1
- old
+ new
@@ -182,16 +182,40 @@
end
end
def expand_gem(gemfile, io)
tmpdir = File.join(Dir.tmpdir, gemfile)
- log.info "Expanding #{gemfile} to #{tmpdir}..."
FileUtils.mkdir_p(tmpdir)
- Gem::Package.send(:open, io) do |pkg|
- pkg.each do |entry|
- pkg.extract_entry(tmpdir, entry)
+ log.info "Expanding #{gemfile} to #{tmpdir}..."
+
+ if Gem::VERSION >= '2.0.0'
+ require 'rubygems/package/tar_reader'
+ reader = Gem::Package::TarReader.new(io)
+ reader.each do |pkg|
+ if pkg.full_name == 'data.tar.gz'
+ Zlib::GzipReader.wrap(pkg) do |gzio|
+ tar = Gem::Package::TarReader.new(gzio)
+ tar.each do |entry|
+ mode = entry.header.mode
+ file = File.join(tmpdir, entry.full_name)
+ FileUtils.mkdir_p(File.dirname(file))
+ File.open(file, 'wb') do |out|
+ out.write(entry.read)
+ out.fsync rescue nil
+ end
+ end
+ end
+ break
+ end
end
+ else
+ Gem::Package.open(io) do |pkg|
+ pkg.each do |entry|
+ pkg.extract_entry(tmpdir, entry)
+ end
+ end
end
+
tmpdir
end
def require_rubygems
require 'rubygems'
\ No newline at end of file