Module AssetHat::CSS::Engines

  1. lib/asset_hat/css.rb

Swappable CSS minification engines.

Methods

public class

  1. cssmin
  2. weak

Public class methods

cssmin (input_string)

CSS minification engine that simply uses the CSSMin gem, a Ruby port of Lecomte’s YUI Compressor and Schlueter’s PHP cssmin.

Sources:

[show source]
     # File lib/asset_hat/css.rb, line 108
108:       def self.cssmin(input_string)
109:         CSSMin.minify(input_string)
110:       end
weak (input_string)

Barebones CSS minification engine that only strips whitespace from the start and end of every line, including linebreaks. For safety, doesn’t attempt to parse the CSS itself.

[show source]
     # File lib/asset_hat/css.rb, line 86
 86:       def self.weak(input_string)
 87:         input   = StringIO.new(input_string)
 88:         output  = StringIO.new
 89: 
 90:         input.each do |line|
 91:           # Remove indentation and trailing whitespace (including line breaks)
 92:           line.strip!
 93:           next if line.blank?
 94: 
 95:           output.write line
 96:         end
 97: 
 98:         output.rewind
 99:         output.read
100:       end