Permalink
Browse files

packr integration

git-svn-id: http://bundle-fu.googlecode.com/svn/trunk@62 1db77ec0-6337-0410-9320-454da9aca44f
  • Loading branch information...
1 parent b7ecbb8 commit f99b8b9d57f9f55b8aa1ff425e9485166edfa9a4 timcharper committed Oct 31, 2007
Showing with 31 additions and 1 deletion.
  1. +6 −1 lib/bundle_fu.rb
  2. +25 −0 test/functional/bundle_fu_test.rb
View
@@ -27,7 +27,12 @@ def bundle_js_files(filenames=[], options={})
output = ""
bundle_files(filenames) { |filename, content|
if options[:compress]
- JSMinimizer.minimize_content(content)
+ if Object.const_defined?("Packr")
+ # use Packr plugin (http://blog.jcoglan.com/packr/)
+ Packr.new.pack(content, options[:packr_options] || {:shrink_vars => false, :base62 => true})
+ else
+ JSMinimizer.minimize_content(content)
+ end
else
content
end
@@ -20,6 +20,31 @@ def test__bundle_js_files__should_include_js_content
assert_public_files_match("/javascripts/cache/bundle.js", "function js_1()")
end
+ def test__bundle_js_files__should_use_packr
+ Object.send :class_eval, <<EOF
+ class ::Object::Packr
+ def initialize
+ end
+
+ def pack(content, options={})
+ "PACKR!" + options.inspect
+ end
+
+ end
+EOF
+
+ @mock_view.bundle() { @@content_include_all }
+ assert_public_files_match("/javascripts/cache/bundle.js", "PACKR")
+ purge_cache
+
+ @mock_view.bundle(:packr_options => {:packr_options_here => "hi_packr"}) { @@content_include_all }
+ assert_public_files_match("/javascripts/cache/bundle.js", "packr_options_here", "Should include packr_options")
+
+
+ Object.send :remove_const, "Packr"
+
+ end
+
def test__bundle_js_files__should_default_to_not_compressed_and_include_override_option
@mock_view.bundle() { @@content_include_all }
default_content = File.read(public_file("/javascripts/cache/bundle.js"))

0 comments on commit f99b8b9

Please sign in to comment.