Ever wondered what a Ruby gem file actually is? It's really just a tar file which contains a few other Gzip compressed tar files. Given I have the .gem file, if I want to extract it, I can use the super simple API in the rubygems part of the stdlib.
require 'rubygems/package'
gem = Gem::Package.new('my_gem.gem')
gem.extract_files('to_this_directory')