Skip to content

Commit

Permalink
more ruby way count_download
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Aug 30, 2012
1 parent 094e90f commit adc504e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions count_downloads2.rb
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby

require 'open-uri'
require 'json'

repo = ARGV[0] || "railsinstaller/railsinstaller-nix"
url = "https://api.github.com/repos/#{repo}/downloads"

open(url) do |res|
data = JSON.load(res).map{ |file|
[
File.basename(file["html_url"]),
file["download_count"]
]
}
puts data.map{|touple| touple*" " }
puts data.map{|name,count| count}.inject(&:+)
end

0 comments on commit adc504e

Please sign in to comment.