Skip to content

Instantly share code, notes, and snippets.

@juno
Created April 9, 2011 17:23
Show Gist options
  • Save juno/911573 to your computer and use it in GitHub Desktop.
Save juno/911573 to your computer and use it in GitHub Desktop.
display runtime gem information in ./Gemfile
#!/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
@juno
Copy link
Author

juno commented Apr 9, 2011

@juno
Copy link
Author

juno commented Apr 12, 2011

Added -g, --group option.

グループを指定できるようにしました。

@juno
Copy link
Author

juno commented Apr 16, 2011

rubygems.orgに存在しないgemが、:source => '...'で指定された場合に落ちる問題を修正した。

@juno
Copy link
Author

juno commented Apr 22, 2011

appraiserというgemにパッケージングしました。

https://github.com/juno/appraiser

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