def execute
specs = []
gem = get_one_gem_name
if local? then
if File.exist? gem then
specs << Gem::Format.from_file_by_path(gem).spec rescue nil
end
if specs.empty? then
specs.push(*Gem.source_index.search(/\A#{gem}\z/, options[:version]))
end
end
if remote? then
Gem::SourceInfoCache.cache_data.each do |_,sice|
specs.push(*sice.source_index.search(gem, options[:version]))
end
end
if specs.empty? then
alert_error "Unknown gem '#{gem}'"
terminate_interaction 1
end
output = lambda { |s| say s.to_yaml; say "\n" }
if options[:all] then
specs.each(&output)
else
spec = specs.sort_by { |s| s.version }.last
output[spec]
end
end