peteog/sinatra-simple-assets — pull request #1 by gkellogg (2012-02-21 19:04:47+00:00)
Title: Recover from lack of JS runtime in production

In a hosting environment where there is no JavaScript runtime, Assets#path_for, calls Bundle#name and Bundle#hashed_path, both of which rely on Bundle#content, which uses Uglifier and CSSMin. Uglifier depends on a JavaScript runtime environment on the server, which shouldn't be necessary if pre-compilation is done in development, and may not be available on the hosting environment.

This change moves the require for 'uglifier' and 'cssmin' into #content, and adds a rescue clause in #hash to look up the have from the most recent complied assets, removing the dependency on the runtime in a production enviornment. Arguably, it shouldn't even attempt to calculate a hash in production, and look for compiled assets based on the filename pattern, but this change doesn't go there.