From a3fd3bc7ebfdda5617d49950ceba8ffe25ec8d9b Mon Sep 17 00:00:00 2001 From: Mario Freitas Date: Sun, 7 Nov 2010 02:41:55 +0900 Subject: [PATCH 1/2] ruby 1.9.x compatibility fix --- lib/bundle_fu/js_minimizer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From dfb55d3024cecb1ee8420250a1b2376dcdfdb1e6 Mon Sep 17 00:00:00 2001 From: Mario Freitas Date: Sun, 7 Nov 2010 02:42:45 +0900 Subject: [PATCH 2/2] support for YUI css/js compressors --- lib/bundle_fu.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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