Class: Rapper::Compressors::CSSCompressor

Inherits:
Compressor
  • Object
show all
Defined in:
lib/rapper/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)


95
96
97
98
99
# File 'lib/rapper/compressors.rb', line 95

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

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



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rapper/compressors.rb', line 83

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