Class: RapperLite::Compressors::JSCompressor
- Inherits:
-
Compressor
- Object
- Compressor
- RapperLite::Compressors::JSCompressor
- Defined in:
- lib/rapper_lite/compressors.rb
Overview
Uses YUI Compressor (via Sam Stephenson’s yui-compressor gem) to compress JavaScrpt.
Class Method Summary collapse
Methods inherited from Compressor
Class Method Details
.compressor_available? ⇒ Boolean
102 103 104 105 106 |
# File 'lib/rapper_lite/compressors.rb', line 102 def self.compressor_available? YUI::JavaScriptCompressor.is_a?( Class ) rescue NameError false end |
.do_compress(file_path, opts = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rapper_lite/compressors.rb', line 89 def self.do_compress( file_path, opts={} ) return unless compressor_available? compressor = YUI::JavaScriptCompressor.new( opts ) js = read_file( file_path ) destination = writable_file( file_path ) destination.write( compressor.compress( js ) ) destination.write "\n" destination.close end |