Class: Pubba::Assets::YUIMinifier

Inherits:
Minifier
  • Object
show all
Defined in:
lib/pubba/assets/yui_minifier.rb

Class Method Summary collapse

Class Method Details

.minify(folder, handler) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pubba/assets/yui_minifier.rb', line 7

def self.minify(folder, handler)
  compressor = get_compressor(handler)
  Dir.glob("#{folder}/*.*") do |file|
    begin
      compressed_contents = compressor.compress( File.read(file) )
      File.open(file, "w") {|f| f.write( compressed_contents) }
    rescue YUI::Compressor::RuntimeError => e
      puts "> Compressor encountered an error in #{file}"
    end
  end
end