Class: Awestruct::Extensions::Minify
- Inherits:
-
Object
- Object
- Awestruct::Extensions::Minify
- Defined in:
- lib/awestruct/extensions/minify.rb
Defined Under Namespace
Classes: JSCompressor
Instance Method Summary collapse
-
#initialize(types = [ :js ]) ⇒ Minify
constructor
A new instance of Minify.
- #transform(site, page, input) ⇒ Object
Constructor Details
#initialize(types = [ :js ]) ⇒ Minify
Returns a new instance of Minify.
54 55 56 |
# File 'lib/awestruct/extensions/minify.rb', line 54 def initialize(types = [ :js ]) @types = types end |
Instance Method Details
#transform(site, page, input) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/awestruct/extensions/minify.rb', line 58 def transform(site, page, input) if site.minify ext = File.extname(page.output_path) if !ext.empty? ext_sym = ext[1..-1].to_sym if @types.include?(ext_sym) case ext_sym when :html $LOG.debug "minifying html #{page.output_path}" if $LOG.debug? input = htmlcompressor(page, input, site.minify_html_opts) when :css # TODO: Figure out how to do this is sass / less and document it #print "minifying css #{page.output_path}" #input = yuicompressor_css(page, input) when :js $LOG.debug "minifying js #{page.output_path}" if $LOG.debug? input = js_compressor(page, input) when :png $LOG.debug "minifying png #{page.output_path}" if $LOG.debug? input = pngcrush(page, input) end end end end input end |