Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pushed new branch: 1_1_0

git-svn-id: http://bundle-fu.googlecode.com/svn/tags/bundle_fu@39 1db77ec0-6337-0410-9320-454da9aca44f
  • Loading branch information...
commit c5152643a7b023a13bbde6508048529269fdd875 2 parents b4ee63e + dec99de
timcharper authored
View
8 lib/bundle_fu.rb
@@ -10,16 +10,18 @@ def each_read_file(filenames=[])
filenames.each{ |filename|
output = "/* -------------- #{filename} ------------- */ "
output << "\n"
- output << (File.read(File.join(RAILS_ROOT, "public", filename)) rescue ( return "/* FILE READ ERROR! */"))
+ output << (File.read(File.join(RAILS_ROOT, "public", filename)) rescue ( "/* FILE READ ERROR! */"))
output << "\n"
yield filename, output
}
end
- def bundle_js_files(filenames=[], output_filename = "", options={})
+ def bundle_js_files(filenames=[], options={})
output = ""
each_read_file(filenames) { |filename, content|
+ output << content
}
+ output
end
# rewrites a relative path to an absolute path, removing excess "../" and "./"
@@ -124,7 +126,7 @@ def bundle(options={}, &block)
FileUtils.rm_f(abs_path)
else
# call bundle_css_files or bundle_js_files to bundle all files listed. output it's contents to a file
- output = BundleFu.send("bundle_#{filetype}_files", new_filelist.filenames, output_filename)
+ output = BundleFu.send("bundle_#{filetype}_files", new_filelist.filenames)
File.open( abs_path, "w") {|f| f.puts output } if output
end
new_filelist.save_as(abs_filelist_path)
View
2  test/fixtures/public/javascripts/js_1.js
@@ -1 +1 @@
-js_1
+function js_1() { alert('hi')};
View
2  test/fixtures/public/javascripts/js_2.js
@@ -1 +1 @@
-js_3
+function js_2() { alert('hi');};
View
2  test/fixtures/public/javascripts/js_3.js
@@ -1 +1 @@
-js_2
+function js_3() { alert('hi')};
View
7 test/functional/bundle_fu_test.rb
@@ -27,6 +27,12 @@ def teardown
purge_cache
end
+ def test__bundle_js_files__should_include_js_content
+ @mock_view.bundle { @@content_include_all }
+
+ assert_public_files_match("/javascripts/cache/bundle.js", "function js_1()")
+ end
+
def test__content_remains_same__shouldnt_refresh_cache
@mock_view.bundle { @@content_include_some }
@@ -107,6 +113,7 @@ def test__bundle__css_only__should_output_css_include_statement
end
def test__nonexisting_file__should_use_blank_file_created_at_0_mtime
+# dbg
@mock_view.bundle { %q{<script src="/javascripts/non_existing_file.js?1000" type="text/javascript"></script>} }
assert_public_files_match(cache_files("bundle").grep(/javascripts/), "FILE READ ERROR")
View
12 test/functional/js_bundle_test.rb
@@ -0,0 +1,12 @@
+require File.join(File.dirname(__FILE__), '../test_helper.rb')
+
+class JSBundleTest < Test::Unit::TestCase
+
+
+ def test__bundle_js_files__should_include_contents
+ bundled_js = BundleFu.bundle_css_files(["/javascripts/js_1.js"])
+# puts bundled_js
+# function js_1
+ assert_match("function js_1", bundled_js)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.