From a2fc3a0f495c10baebb532a9106dc47f9a18d939 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Mon, 12 Mar 2012 13:52:37 -0500 Subject: Remove sprockets integration on ActionPack --- actionpack/lib/sprockets/compressors.rb | 85 --------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 actionpack/lib/sprockets/compressors.rb (limited to 'actionpack/lib/sprockets/compressors.rb') diff --git a/actionpack/lib/sprockets/compressors.rb b/actionpack/lib/sprockets/compressors.rb deleted file mode 100644 index 8b728d6570..0000000000 --- a/actionpack/lib/sprockets/compressors.rb +++ /dev/null @@ -1,85 +0,0 @@ -module Sprockets - module Compressors - extend self - - @@css_compressors = {} - @@js_compressors = {} - @@default_css_compressor = nil - @@default_js_compressor = nil - - def register_css_compressor(name, klass, options = {}) - @@default_css_compressor = name.to_sym if options[:default] || @@default_css_compressor.nil? - @@css_compressors[name.to_sym] = { :klass => klass.to_s, :require => options[:require] } - end - - def register_js_compressor(name, klass, options = {}) - @@default_js_compressor = name.to_sym if options[:default] || @@default_js_compressor.nil? - @@js_compressors[name.to_sym] = { :klass => klass.to_s, :require => options[:require] } - end - - def registered_css_compressor(name) - find_registered_compressor name, @@css_compressors, @@default_css_compressor - end - - def registered_js_compressor(name) - find_registered_compressor name, @@js_compressors, @@default_js_compressor - end - - # The default compressors must be registered in default plugins (ex. Sass-Rails) - register_css_compressor(:scss, 'Sass::Rails::Compressor', :require => 'sass/rails/compressor', :default => true) - register_js_compressor(:uglifier, 'Uglifier', :require => 'uglifier', :default => true) - - # Automaticaly register some compressors - register_css_compressor(:yui, 'YUI::CssCompressor', :require => 'yui/compressor') - register_js_compressor(:closure, 'Closure::Compiler', :require => 'closure-compiler') - register_js_compressor(:yui, 'YUI::JavaScriptCompressor', :require => 'yui/compressor') - - private - - def find_registered_compressor(name, compressors_hash, default_compressor_name) - if name.respond_to?(:to_sym) - compressor = compressors_hash[name.to_sym] || compressors_hash[default_compressor_name] - require compressor[:require] if compressor[:require] - compressor[:klass].constantize.new - else - name - end - end - end - - # An asset compressor which does nothing. - # - # This compressor simply returns the asset as-is, without any compression - # whatsoever. It is useful in development mode, when compression isn't - # needed but using the same asset pipeline as production is desired. - class NullCompressor #:nodoc: - def compress(content) - content - end - end - - # An asset compressor which only initializes the underlying compression - # engine when needed. - # - # This postpones the initialization of the compressor until - # #compress is called the first time. - class LazyCompressor #:nodoc: - # Initializes a new LazyCompressor. - # - # The block should return a compressor when called, i.e. an object - # which responds to #compress. - def initialize(&block) - @block = block - end - - def compress(content) - compressor.compress(content) - end - - private - - def compressor - @compressor ||= (@block.call || NullCompressor.new) - end - end -end -- cgit v1.2.3