Sha256: c49cc3cd23008985eb70f3bf31809e67b1dc82ad9d0ef89057f1eb62c379aeac

Contents?: true

Size: 865 Bytes

Versions: 10

Compression:

Stored size: 865 Bytes

Contents

module Distil

  COMPRESSOR= File.expand_path("#{VENDOR_DIR}/yuicompressor-2.4.2.jar")
    
  module Minified
    
    def filename
      minified_name
    end
    
    def external_files
      []
    end
    
    def write_output
      return if up_to_date
      @up_to_date= true
      
    	# Run the Y!UI Compressor
    	if (!File.exist?(concatenated_name))
    	  error("Missing source file for minify: #{concatenated_name}")
    	  return
  	  end
  	  
    	result= system "java -jar #{COMPRESSOR} \"#{concatenated_name}\" -o \"#{filename}\""
    	if (!result)
    	  error("Failed to minify: #{concatenated_name}")
    	  return
  	  end
    	
    	if 'css'==extension
    		buffer= File.read(filename)
    		File.open(filename, "w") { |f|
    		  f.write(buffer.gsub(/\}/,"}\n").gsub(/.*@import url\(\".*\"\);/,''))
  		  }
      end 
    end
  
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
distil-0.13.6 lib/distil/product/minified.rb
distil-0.13.5 lib/distil/product/minified.rb
distil-0.13.4 lib/distil/product/minified.rb
distil-0.13.3 lib/distil/product/minified.rb
distil-0.13.2 lib/distil/product/minified.rb
distil-0.13.1 lib/distil/product/minified.rb
distil-0.13.0 lib/distil/product/minified.rb
distil-0.12.6 lib/distil/product/minified.rb
distil-0.12.4 lib/distil/product/minified.rb
distil-0.12.3 lib/distil/product/minified.rb