Class: Stylo::CssMinifier

Inherits:
Object
  • Object
show all
Defined in:
lib/stylo/css_minifier.rb

Class Method Summary collapse

Class Method Details

.minify(original) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/stylo/css_minifier.rb', line 3

def self.minify(original)
  result = original.gsub /\s+/, ' '
  result = result.gsub /\/\*.*?\*\//s, ''
  result = result.gsub '; ', ';'
  result = result.gsub ': ', ':'
  result = result.gsub ' {', '{'
  result = result.gsub '{ ', '{'
  result = result.gsub ', ', ','
  result = result.gsub '} ', '}'
  result = result.gsub ';}', '}'
  result.strip
end