Created
June 9, 2014 02:54
-
-
Save tily/ddbdd25ca1ced740a43c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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