Sha256: de85b56fda86f6c81a8cf2f223fe8d341c95482539e21417cec035c37bd9f82d
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'csso/version' module Csso autoload :JsLib, 'csso/js_lib' autoload :Compressor, 'csso/compressor' def self.js_api @csso ||= Csso::JsLib.new end def self.install(sprockets) unless sprockets raise "no compatible sprockets found" unless Sprockets.respond_to? :register_compressor Sprockets.register_compressor('text/css', :csso, Compressor) return end if sprockets.respond_to? :register_compressor sprockets.register_compressor('text/css', :csso, Compressor) sprockets.css_compressor = :csso else Sprockets::Compressors.register_css_compressor(:csso, 'Csso::Compressor', :default => true) end end def self.optimize(css, maniac_mode=false, structural_optimization=true) if maniac_mode maniac_mode = 4 unless maniac_mode.is_a?(Fixnum) && maniac_mode > 0 begin prev_css = css css = Optimizer.new.optimize(css, structural_optimization) maniac_mode -= 1 end while maniac_mode > 0 && prev_css != css css else Optimizer.new.optimize(css, structural_optimization) end end class Optimizer def optimize(css, structural_optimization=true) return nil unless css.is_a?(String) return css if css.size <= 3 Csso.js_api.compress(css, structural_optimization) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csso-rails-0.4.1 | lib/csso.rb |