GREATseth

runpacker.

Posted in everything else by Seth Rasmussen on June 9, 2008

I’ve noticed that RubyGems(as of version 1.0.1, anyway) does not offer a convenient way to unpack a specified gem and all of its dependencies. So, I decided to try to come up with something simple to work around that. After a few minutes inspecting the Gem API and some help from drbrain, I ended up with this:

#!/usr/bin/env ruby

if ARGV.empty?
  puts "Usage: runpack gem_name"
  exit
end

require "rubygems"
gem_specified = ARGV.first
Gem.gem gem_specified
gems_to_unpack = [gem_specified] +
  Gem.loaded_specs[gem_specified].dependencies.map { |d| d.name }
gems_to_unpack.each { |g| system "gem unpack #{g}" }
Tagged with: ,