Created
April 9, 2011 17:23
-
-
Save juno/911573 to your computer and use it in GitHub Desktop.
display runtime gem information in ./Gemfile
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
#!/usr/bin/env ruby | |
require 'ansi/code' | |
require 'bundler' | |
require 'json' | |
require 'open-uri' | |
class Integer | |
def to_currency | |
self.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\1,').reverse | |
end | |
end | |
include ANSI::Code | |
begin | |
Bundler.definition.dependencies.select{ |i| i.groups.include? :default }.each do |dependency| | |
begin | |
json = JSON.parse(open("http://rubygems.org/api/v1/gems/#{dependency.name}.json").read) | |
name = json['name'] | |
authors = json['authors'] | |
downloads = json['downloads'].to_currency | |
project_uri = json['project_uri'] | |
doc_uri = json['documentation_uri'] | |
src_uri = json['source_code_uri'] | |
info = json['info'].split("\n").first.strip | |
puts green { name } + ' (by ' + authors + ')' | |
puts 'Downloads: ' + blue { downloads } | |
puts 'Project : ' + cyan { underline { project_uri } } if project_uri | |
puts 'Document : ' + cyan { underline { doc_uri } } if doc_uri | |
puts 'Source : ' + cyan { underline { src_uri } } if src_uri | |
puts info | |
puts '-' * 60 | |
rescue OpenURI::HTTPError => e | |
puts green { dependency.name } | |
puts 'Source : ' + cyan { underline { dependency.source } } | |
puts '-' * 60 | |
end | |
end | |
rescue => e | |
puts "Error: #{e}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
appraiserというgemにパッケージングしました。
https://github.com/juno/appraiser