Created
May 13, 2010 10:44
-
-
Save eladkehat/399714 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 | |
# Explodes a minified css file, e.g. using YUI Compressor (http://developer.yahoo.com/yui/compressor/) | |
# Minified css (unlike obfuscated javascript) is still easily readable if only the spaces, newlines and | |
# indentations are put back in. This little ruby script does this with some simple regular expressions. | |
fn = ARGV[0] | |
css = IO.read fn | |
replacements = [ [/\s*\{/, " {\n\t"], [/;/, ";\n\t"], [/\t?\}/, "}\n\n"], ] | |
replacements.each { |re, s| css.gsub! re, s } | |
fout = File.join(File.dirname(fn), File.basename(fn, ".*") + ".exploded." + File.extname(fn)) | |
File.open(fout, 'w') {|f| f.write css } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment