Class: RapperLite::Compressors::CSSCompressor

Inherits:
Compressor
  • Object
show all
Defined in:
lib/rapper_lite/compressors.rb

Overview

Use Richard Hulse’s Ruby port of the YUI CSS Compressor to compress the contents of a CSS file.

Class Method Summary collapse

Methods inherited from Compressor

compress

Class Method Details

.compressor_available?Boolean

Returns:

  • (Boolean)


77
78
79
80
81
# File 'lib/rapper_lite/compressors.rb', line 77

def self.compressor_available?
  YUI::CSS.is_a?( Class )
rescue NameError
  false
end

.do_compress(file_path, opts = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rapper_lite/compressors.rb', line 65

def self.do_compress( file_path, opts={} )
  return unless compressor_available?
  
  css = read_file( file_path )
  css = YUI::CSS.compress( css )
  destination = writable_file( file_path )
  
  destination.write( css )
  destination.write "\n"
  destination.close
end