Skip to content

Instantly share code, notes, and snippets.

@mbreit
Created February 22, 2012 15:31
Show Gist options
  • Save mbreit/1885559 to your computer and use it in GitHub Desktop.
Save mbreit/1885559 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# http://smacss.com/
# Box
# Border
# Background
# Text
# Other
properties = {
box: %w(display float position left top height width),
border: %w(border),
background: %w(background),
text: %w(font color text letter)
}
new_order = Hash.new { [] }
ARGF.each do |line|
property = line.split(/:/)[0].strip
key = (properties.find { |k, v| v.include?(property) } || [:other]).first
new_order[key] = new_order[key].push(line.chomp)
end
puts (properties.keys + [:other]).map { |key| "/* #{key} */\n" + new_order[key].sort.join("\n") }.join("\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment