Created
November 20, 2012 03:36
-
-
Save augustf/4115788 to your computer and use it in GitHub Desktop.
Get latest Concerto version from Github or How I learned to hate the OpenSSL Nanny State
This file contains hidden or 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
#!/usr/bin/env ruby | |
#https://api.github.com/repos/concerto/concerto/git/refs/tags | |
require 'net/https' | |
require 'uri' | |
require 'json' | |
uri = URI.parse('https://api.github.com/repos/concerto/concerto/git/refs/tags') | |
http = Net::HTTP.new(uri.host, uri.port) | |
if uri.scheme == "https" # enable SSL/TLS | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_PEER | |
http.ca_file = File.join(File.dirname(__FILE__), "cacert.pem") | |
end | |
http.start { | |
http.request_get(uri.path) {|res| | |
@versions = Array.new | |
JSON.parse(res.body).each do |tag| | |
@versions << tag['ref'].gsub(/refs\/tags\//,'') | |
end | |
@versions.sort! {|x,y| y <=> x } | |
puts @versions[0] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment