Created
February 5, 2014 18:01
-
-
Save rubiii/8829644 to your computer and use it in GitHub Desktop.
tells you the latest version number of a gem
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 | |
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 |
Author
rubiii
commented
Feb 5, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment