Module: Smurf::Stylesheet::Minifier
- Defined in:
- lib/smurf/stylesheet.rb
Instance Method Summary collapse
-
#compress_whitespace ⇒ Object
.*? is a non-greedy match on anything.
- #remove_comments ⇒ Object
- #remove_spaces_inside_block ⇒ Object
- #remove_spaces_outside_block ⇒ Object
- #trim_last_semicolon ⇒ Object
Instance Method Details
#compress_whitespace ⇒ Object
.*? is a non-greedy match on anything
20 |
# File 'lib/smurf/stylesheet.rb', line 20 def compress_whitespace; compress!(/\s+/, ' '); end |
#remove_comments ⇒ Object
21 |
# File 'lib/smurf/stylesheet.rb', line 21 def remove_comments; compress!(/\/\*.*?\*\/\s?/, ''); end |
#remove_spaces_inside_block ⇒ Object
25 26 27 28 29 30 |
# File 'lib/smurf/stylesheet.rb', line 25 def remove_spaces_inside_block compress!(/\{(.*?)(?=\})/) do |m| # remove spaces in the labels/attributes m.gsub(/(?:\A|\s*;)(.*?)(?::\s*|\z)/) { |n| n.gsub(/\s/, '') }.strip end end |
#remove_spaces_outside_block ⇒ Object
22 23 24 |
# File 'lib/smurf/stylesheet.rb', line 22 def remove_spaces_outside_block compress!(/(\A|\})(.*?)\{/) { |m| m.gsub(/\s?([}{,])\s?/, '\1') } end |
#trim_last_semicolon ⇒ Object
31 |
# File 'lib/smurf/stylesheet.rb', line 31 def trim_last_semicolon; compress!(/;(?=\})/, ''); end |