Skip to content
Browse files

pushed new branch: 1_2

git-svn-id: http://bundle-fu.googlecode.com/svn/tags/bundle_fu@66 1db77ec0-6337-0410-9320-454da9aca44f
  • Loading branch information...
2 parents a6949b3 + c13f84b commit 2764c3b723f1d901bd2dc49d7dfb84136d096d11 timcharper committed
Showing with 39 additions and 2 deletions.
  1. +14 −2 lib/bundle_fu.rb
  2. +25 −0 test/functional/bundle_fu_test.rb
View
16 lib/bundle_fu.rb
@@ -24,14 +24,26 @@ def bundle_files(filenames=[])
end
def bundle_js_files(filenames=[], options={})
- output = ""
+ output =
bundle_files(filenames) { |filename, content|
if options[:compress]
- JSMinimizer.minimize_content(content)
+ if Object.const_defined?("Packr")
+ content
+ else
+ JSMinimizer.minimize_content(content)
+ end
else
content
end
}
+
+ 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})
+ else
+ output
+ end
+
end
def bundle_css_files(filenames=[], options = {})
View
25 test/functional/bundle_fu_test.rb
@@ -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 2764c3b

Please sign in to comment.
Something went wrong with that request. Please try again.