Use gem to get library version
require 'rubygems/remote_installer'
require 'yaml'
def format_gems(gems)
gem_versions = gems.inject({}) { |h, gem| (h[gem.name] ||= []) << gem; h}
gem_versions.keys.sort.each do |name|
versions = gem_versions[name].collect { |gem| gem.version.to_s }
puts "#{name} is available in these versions: #{versions.join(', ')}"
end
end
format_gems(Gem::RemoteInstaller.new.search(/.*/).flatten)
Related examples in the same category