Unpack your unruly gems!
November 13th, 2009
Unpacking Gems doesn’t always work in some projects for various annoying reasons.
So this is just my hammer for the nail.
Some gems really don’t like to be unpacked… see:
def muck_gems
['capistrano_mailer','super_exception_notifier','sanitize_email','csv_pirate']
end
# execute commands in a different directory
def inside(dir, &block)
FileUtils.cd(dir) { block.arity == 1 ? yield(dir) : yield }
end
desc "unpacks all muck gems into vendor/gems using versions installed on the local machine."
task :unpack do
gem_path = File.join(File.dirname(__FILE__), 'vendor', 'gems')
FileUtils.mkdir_p(gem_path) unless File.exists?(gem_path)
inside gem_path do
muck_gems.each do |gem_name|
system("gem unpack #{gem_name}")
#Don't want it in vendor/gems, needs to be in gem's own folder, and that's harder to achieve
dir = Dir.entries(gem_path).select {|x| x.match(gem_name)}.first
system("gem specification #{gem_name} > #{gem_path}/#{dir}/.specification")
end
end
end
References: justinball.com metaclass.org
Sorry, comments are closed for this article.