def execute
specs = []
gem = get_one_gem_name
dep = Gem::Dependency.new gem, options[:version]
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(dep))
end
end
if remote? then
found = Gem::SpecFetcher.fetcher.fetch dep
specs.push(*found.map { |spec,| spec })
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