diff --git a/lib/bundle_fu.rb b/lib/bundle_fu.rb index 5991b97..b6868c7 100644 --- a/lib/bundle_fu.rb +++ b/lib/bundle_fu.rb @@ -29,6 +29,8 @@ def bundle_js_files(filenames=[], options={}) if options[:compress] if Object.const_defined?("Packr") content + elsif Object.const_defined?("YUI") + content else JSMinimizer.minimize_content(content) end @@ -40,6 +42,9 @@ def bundle_js_files(filenames=[], options={}) if Object.const_defined?("Packr") # use Packr plugin (http://blog.jcoglan.com/packr/) Packr.new.pack(output, options[:packr_options] || {:shrink_vars => false, :base62 => false}) + elsif Object.const_defined?("YUI") + compressor = YUI::JavaScriptCompressor.new(options[:yui_js_options] || {:munge => true}) + compressor.compress(output) else output end @@ -48,7 +53,13 @@ def bundle_js_files(filenames=[], options={}) def bundle_css_files(filenames=[], options = {}) bundle_files(filenames) { |filename, content| - BundleFu::CSSUrlRewriter.rewrite_urls(filename, content) + content = BundleFu::CSSUrlRewriter.rewrite_urls(filename, content) + # use YUI compressor + if Object.const_defined?("YUI") + compressor = YUI::CssCompressor.new(options[:yui_css_options] || {}) + content = compressor.compress(content) + end + content } end end diff --git a/lib/bundle_fu/js_minimizer.rb b/lib/bundle_fu/js_minimizer.rb index cef0461..4ca7789 100644 --- a/lib/bundle_fu/js_minimizer.rb +++ b/lib/bundle_fu/js_minimizer.rb @@ -47,7 +47,7 @@ def isAlphanum(c) return false if !c || c == EOF return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || - c == '\\' || c[0] > 126) + c == '\\' || c[0..0] > '~') end # get -- return the next character from input. Watch out for lookahead. If @@ -214,4 +214,4 @@ def self.minimize_content(content) js_minimizer.output.string end -end \ No newline at end of file +end