Created
June 6, 2009 02:44
-
-
Save jaredatron/124649 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env ruby | |
| # gets you ncss files 90% the way to sass | |
| ARGV.each do |path| | |
| next unless File.exists?(path) | |
| sass_path = path.sub(/#{File.extname(path)}$/,'.sass') | |
| File.open(sass_path, 'w').write File.open(path).read. | |
| gsub(/([\w-]+):\s+(.*?);/, ':\1 \2'). # flopping the colon | |
| gsub(/[ ]*(\{|\})[ ]*/, ''). # removing any { } | |
| gsub(/(^[ ]+)\./, '\1&.'). # replacing nested .something selectors with &.something | |
| gsub(/(^[ ]+)\*\./, '\1.') # replacing nested *.something selectors with .something | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment