Last active
August 10, 2019 13:41
-
-
Save muizidn/75ce4ee98458009eab7b6bd03e95d345 to your computer and use it in GitHub Desktop.
Check git size
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
require 'open-uri' | |
require 'json' | |
url = ARGV[0] | |
uri = URI.parse(url) | |
api_uri = "https://api.github.com/repos" + uri.path | |
puts "fetch from: #{api_uri}" | |
json_string = URI.parse(api_uri).read | |
json = JSON.parse(json_string) | |
size = json["size"] | |
reposize = case size | |
when 0..1024 then "#{size} kb" | |
when 1024..1024**2 then "#{size / 1024}+ mb" | |
when 1024**2..1024**3 then "#{size / 1024**2}+ gb" | |
when 1024**3..1024**4 then "#{size / 1024**3}+ tb" | |
when 1024**4..1024**5 then "#{size / 1024**4}+ pb" | |
else "Unknown" | |
end | |
puts "Size #{size} = #{reposize}"% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment