Created
May 16, 2011 22:19
-
-
Save tizoc/975509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'rubygems' | |
gem_dirs = [] | |
basedir = 'deps' | |
FileUtils.mkdir_p(basedir) | |
ARGV.each do |gemset| | |
File.open(gemset, 'r').each_line do |line| | |
next if line =~ /^#.*/ | |
line = line.gsub(' -v', '-') | |
Gem.path.each do |gempath| | |
gemdir = File.join(gempath, 'gems', line.strip) | |
if File.directory?(gemdir) | |
gem_dirs << gemdir | |
break | |
end | |
end | |
end | |
end | |
def recursive_link(src, dst) | |
if File.directory?(src) | |
srcname = File.basename(src) | |
fulldst = File.join(dst, srcname) | |
FileUtils.mkdir_p(fulldst) | |
Dir.entries(src).each do |entry| | |
next if ['.', '..'].include? entry | |
recursive_link(File.join(src, entry), fulldst) | |
end | |
else | |
FileUtils.ln_sf(src, dst) | |
end | |
end | |
gem_dirs.each do |gem_dir| | |
Dir.entries(gem_dir).each do |dir| | |
next if ['.', '..', 'spec'].include? dir | |
recursive_link(File.join(gem_dir, dir), basedir) | |
end | |
end | |
# Uncomment to override rubygems and not pay for it at runtime | |
# [['rubygems.rb', "module Kernel; def gem(*args); end end"], | |
# ['ubygems.rb', "require 'rubygems'"], | |
# ].each do |file, data| | |
# path = File.join(libsdir, file) | |
# File.open(path, 'wb'){|f| f.puts(data)} | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment