Skip to content

Instantly share code, notes, and snippets.

@mojombo
Created March 20, 2009 22:39
Show Gist options
  • Select an option

  • Save mojombo/82623 to your computer and use it in GitHub Desktop.

Select an option

Save mojombo/82623 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rubygems/format'
ROOT_DIR = '/home/github/gems/'
CACHE_DIR = ROOT_DIR + 'cache'
SPEC_DIR = ROOT_DIR + 'specifications'
Dir.glob("#{CACHE_DIR}/*.gem") do |f|
begin
spec = Gem::Format.from_file_by_path(f).spec
code = spec.to_ruby
file = "#{SPEC_DIR}/#{spec.file_name}spec"
if File.exist?(file)
puts "Skipping existing gemspec #{file}"
next
end
puts "Writing #{code.size} bytes to #{file}"
File.open(file, 'w') { |x| x.write(code) }
rescue => e
puts e.message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment