Sha256: 827221e7f8e3fddfc5f9999f5085abc0d172a8d5efc9236f4bfb77cfa7ce5d47
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 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) if sprockets.respond_to? :register_compressor sprockets.register_compressor('text/css', :csso, Compressor.new) 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
csso-rails-0.3.4 | lib/csso.rb |
csso-rails-0.3.3 | lib/csso.rb |
csso-rails-0.3.2 | lib/csso.rb |
csso-rails-0.3.1 | lib/csso.rb |
csso-rails-0.3.0 | lib/csso.rb |