Created
October 18, 2011 20:03
-
-
Save alexch/1296540 to your computer and use it in GitHub Desktop.
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
data = <<TEXT | |
Lion (10.7.1) | |
Mac OS | |
Mac osx | |
Windows 7 | |
Mac osx, leopard | |
Linux | |
OSX | |
OSX | |
Mac OSX (snow leopard) | |
OSX | |
OSX | |
OSX Lion | |
OS X 10.7.1 | |
OSX Lion | |
osx | |
Snow Leopard/Lion | |
Windows 7 | |
Windows 7 | |
Windows 7 | |
Snow Leopard | |
Mac 0S 10.6 | |
Mac OS X 10.6.8 | |
Mac OS X v. 10.6.8 | |
OSX 10.5.8 | |
TEXT | |
hist = {} | |
data.split("\n").each do |os| | |
os = os.strip. | |
gsub("Lion (10.7.1)", "OSX 10.7"). | |
gsub("Mac OSX (snow leopard)", "OSX 10.6"). | |
downcase. | |
gsub("mac osx, leopard", "OSX 10.5"). | |
gsub("mac 0s", "OSX"). | |
gsub(/(osx ?)*lion/i, "OSX 10.7"). | |
gsub(/(osx ?)*snow leopard/i, "OSX 10.6"). | |
gsub(/(osx ?)*leopard/i, "OSX 10.5"). | |
gsub(/(osx ?)*tiger/i, "OSX 10.4"). | |
gsub(/(mac ?)*os ?x?/i, 'OSX'). | |
gsub(/((mac ?)osx ?)+ */, "OSX "). | |
gsub(/v\. ?/, ''). | |
gsub(/(10\.\d)\.\d/, '\\1'). | |
strip | |
hist[os] ||= 0 | |
hist[os] += 1 | |
end | |
require "awesome_print" | |
ap Hash[hist.sort] | |
=begin | |
If it starts with 10.7, you have Lion. | |
If it starts with 10.6, you have Snow Leopard. | |
If it starts with 10.5, you have Leopard. | |
If it starts with 10.4, you have Tiger. | |
If it starts with 10.3, you have Panther. | |
=end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment