Skip to content

Instantly share code, notes, and snippets.

@tily
Created June 9, 2014 02:54
Show Gist options
  • Save tily/ddbdd25ca1ced740a43c to your computer and use it in GitHub Desktop.
Save tily/ddbdd25ca1ced740a43c to your computer and use it in GitHub Desktop.
%w(open-uri nokogiri).each {|x| require x }
URL = 'http://rubygems.org/gems/rubygems-update/versions'
def get_versions
versions = []
doc = Nokogiri::HTML open(URL)
doc.xpath('//ol/li/a').each do |a|
versions << a.text
end
versions
end
def main
versions = get_versions
regexps = versions.map {|v| /^#{Regexp.escape(v)}$/}
puts Regexp.union(*regexps)
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment