Skip to content

Instantly share code, notes, and snippets.

@augustf
Created November 20, 2012 03:36
Show Gist options
  • Save augustf/4115788 to your computer and use it in GitHub Desktop.
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
#!/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