def execute
get_all_gem_names.each do |name|
dependency = Gem::Dependency.new name, options[:version]
path = get_path dependency
unless path then
alert_error "Gem '#{name}' not installed nor fetchable."
next
end
if @options[:spec] then
spec, metadata = get_metadata path
if metadata.nil? then
alert_error "--spec is unsupported on '#{name}' (old format gem)"
next
end
spec_file = File.basename spec.spec_file
open spec_file, 'w' do |io|
io.write metadata
end
else
basename = File.basename path, '.gem'
target_dir = File.expand_path basename, options[:target]
FileUtils.mkdir_p target_dir
Gem::Installer.new(path, :unpack => true).unpack target_dir
say "Unpacked gem: '#{target_dir}'"
end
end
end