Skip to content

Instantly share code, notes, and snippets.

@kylekyle
Created March 4, 2016 06:27
Show Gist options
  • Save kylekyle/a130f46993a0042915fd to your computer and use it in GitHub Desktop.
Save kylekyle/a130f46993a0042915fd to your computer and use it in GitHub Desktop.
Dynamically generate docs from a gem
require 'zlib'
require 'yard'
require 'tmpdir'
require 'stringio'
require 'fileutils'
require 'archive/tar/minitar'
io = StringIO.new File.read('sequel-4.32.0.gem')
catch :finished do
Archive::Tar::Minitar::Input.open(io) do |entries|
entries.each do |entry|
if entry.full_name == 'data.tar.gz'
Zlib::GzipReader.wrap StringIO.new(entry.read) do |gzio|
Dir.mktmpdir do |directory|
Archive::Tar::Minitar.unpack gzio, directory
Dir.chdir directory do
YARD::CLI::Yardoc.run '-c', '--no-stats', '-o', '/Users/kyle/Desktop/BOOM'
end
throw :finished, true
end
end
end
end
end
raise 'could not extract files from gem!'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment