# File lib/rubygems/commands/unpack_command.rb, line 39
  def execute
    get_all_gem_names.each do |name|
      path = get_path name, options[:version]

      if path then
        basename = File.basename(path).sub(/\.gem$/, '')
        target_dir = File.expand_path File.join(options[:target], basename)
        FileUtils.mkdir_p target_dir
        Gem::Installer.new(path, :unpack => true).unpack target_dir
        say "Unpacked gem: '#{target_dir}'"
      else
        alert_error "Gem '#{name}' not installed."
      end
    end
  end