punch
Advanced tools
Comparing version 0.5.35 to 0.5.36
@@ -21,14 +21,21 @@ var _ = require("underscore"); | ||
var build_bundle_tag = function(template_tag, bundle) { | ||
var file_extension = PathUtils.getExtension(bundle, null); | ||
var request_basename = PathUtils.getBasename(bundle, file_extension); | ||
var file_extension = PathUtils.getExtension(bundle, null); | ||
var request_basename = PathUtils.getBasename(bundle, file_extension); | ||
var output_path; | ||
var output_path; | ||
if (fingerprint) { | ||
output_path = (request_basename + "-" + bundle_fingerprints[bundle].getTime() + file_extension); | ||
} else { | ||
output_path = (request_basename + file_extension); | ||
} | ||
if (fingerprint) { | ||
var bundle_fingerprint = bundle_fingerprints[bundle]; | ||
if (bundle_fingerprint) { | ||
output_path = (request_basename + "-" + bundle_fingerprint.getTime() + file_extension); | ||
} else { | ||
// bundle path not found. Return an empty string while logging a message. | ||
console.log("Incorrect bundle path. '" + bundle + "' not available.") | ||
return ""; | ||
} | ||
} else { | ||
output_path = (request_basename + file_extension); | ||
} | ||
return Util.format(template_tag, output_path); | ||
return Util.format(template_tag, output_path); | ||
}; | ||
@@ -35,0 +42,0 @@ |
@@ -15,3 +15,3 @@ { | ||
], | ||
"version": "0.5.35", | ||
"version": "0.5.36", | ||
"homepage": "https://github.com/laktek/punch", | ||
@@ -18,0 +18,0 @@ "author": "Lakshan Perera <lakshan@web2media.net> (http://laktek.com)", |
@@ -8,3 +8,3 @@ var AssetBundleHelperObj = require("../../lib/helpers/asset_bundle_helper"); | ||
it("output the bundled tag when bundling no host is provided and fingerprint is disabled", function(){ | ||
it("output the bundled tag when bundling with no host is provided and fingerprint is disabled", function(){ | ||
spyOn(AssetBundler, "setup"); | ||
@@ -23,3 +23,3 @@ | ||
it("output the bundled tag when bundling no host is provided and fingerprint is enabled", function(){ | ||
it("output the bundled tag when bundling with no host is provided and fingerprint is enabled", function(){ | ||
spyOn(AssetBundler, "setup"); | ||
@@ -52,2 +52,16 @@ | ||
it("output an empty string when bundling an incorrect bundle path", function(){ | ||
spyOn(AssetBundler, "setup"); | ||
spyOn(AssetBundler, "statBundle").andCallFake(function(basename, extension, callback) { | ||
return callback(null, { "mtime": new Date(2012, 7, 25) }); | ||
}); | ||
AssetBundleHelperObj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"], "fingerprint": true }, "bundles": { "/assets/all.css": [ "/assets/initial.css", "/assets/site.css" ]} }); | ||
var spyCallback = jasmine.createSpy(); | ||
AssetBundleHelperObj.get( "/path/test", ".html", { "host": "" }, spyCallback); | ||
expect(AssetBundleHelper.stylesheet_bundle("/assets/invalid_path.css")).toEqual(""); | ||
}); | ||
}); | ||
@@ -99,2 +113,16 @@ | ||
it("output an empty string when bundling an incorrect bundle path", function(){ | ||
spyOn(AssetBundler, "setup"); | ||
spyOn(AssetBundler, "statBundle").andCallFake(function(basename, extension, callback) { | ||
return callback(null, { "mtime": new Date(2012, 7, 25) }); | ||
}); | ||
AssetBundleHelperObj.setup( { "asset_bundling": { "skip_hosts": ["localhost", "127.0.0.1", ".local"], "fingerprint": true }, "bundles": { "/assets/all.js": [ "/assets/jquery.js", "/assets/site.coffee" ]} }); | ||
var spyCallback = jasmine.createSpy(); | ||
AssetBundleHelperObj.get( "/path/test", ".html", { "host": undefined }, spyCallback); | ||
expect(AssetBundleHelper.javascript_bundle("/assets/invalid_path.js")).toEqual(""); | ||
}); | ||
}); |
1020870
8446