Skip to content

Instantly share code, notes, and snippets.

@rubiii
Created February 5, 2014 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubiii/8829644 to your computer and use it in GitHub Desktop.
Save rubiii/8829644 to your computer and use it in GitHub Desktop.
tells you the latest version number of a gem
#!/usr/bin/env ruby
require 'httpclient'
require 'json'
if ARGV.any?
gems = ARGV
else
puts 'feed me some gem name(s)!'
exit
end
client = HTTPClient.new
endpoint = 'https://rubygems.org/api/v1'
gems.each do |gem|
url = "#{endpoint}/gems/#{gem}.json"
response = client.get(url)
if response.status == 404
puts "#{gem}: does not exist"
else
data = JSON.parse(response.body)
version = data['version']
puts "#{gem}: #{version}"
end
end
@rubiii
Copy link
Author

rubiii commented Feb 5, 2014

chmod +x latest
latest sinatra rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment