Skip to content

Instantly share code, notes, and snippets.

@rlivsey
Created March 4, 2010 17:38
Show Gist options
  • Save rlivsey/321937 to your computer and use it in GitHub Desktop.
Save rlivsey/321937 to your computer and use it in GitHub Desktop.
hyphens = 0
underscores = 0
nothing = 0
total = 0
# gem list --remote > remote.txt
File.read("remote.txt").each do |gem_details|
name, version = gem_details.split
if name.include?("_") # also consumes ones with *both* _ and - as per github username-gem_name style gems
underscores += 1
elsif name.include?("-")
hyphens += 1
else
nothing += 1
end
total += 1
end
def percent(total, num)
pc = (num.to_f / total.to_f) * 100.0
"#{pc.ceil}%"
end
puts "out of #{total} gems, #{percent(total, hyphens)} (#{hyphens}) use hyphens, #{percent(total, underscores)} (#{underscores}) use underscores and the other #{percent(total, nothing)} (#{nothing}) are just one word"
At the time of writing:
out of 18068 gems, 46% (8186) use hyphens, 24% (4293) use underscores and the other 31% (5589) are just one word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment