diff --git a/jammit.gemspec b/jammit.gemspec index 537e5416..8abee451 100644 --- a/jammit.gemspec +++ b/jammit.gemspec @@ -25,8 +25,7 @@ Gem::Specification.new do |s| '--exclude' << 'test' << '--main' << 'README' << '--all' - - s.add_dependency 'yui-compressor', ['>= 0.9.3'] + s.add_dependency 'yui-compressor', ['>= 0.9.3'] s.files = Dir['lib/**/*', 'bin/*', 'rails/*', 'jammit.gemspec', 'LICENSE', 'README'] end diff --git a/lib/jammit.rb b/lib/jammit.rb index 42e46fcd..d531b595 100644 --- a/lib/jammit.rb +++ b/lib/jammit.rb @@ -51,7 +51,8 @@ class << self :embed_assets, :package_assets, :compress_assets, :gzip_assets, :package_path, :mhtml_enabled, :include_jst_script, :config_path, :javascript_compressor, :compressor_options, :css_compressor_options, - :template_extension, :template_extension_matcher, :allow_debugging + :template_extension, :template_extension_matcher, :allow_debugging, + :java_disabled attr_accessor :compressors end @@ -181,6 +182,7 @@ def self.check_java_version # complain loudly. def self.disable_compression @compress_assets = false + @java_disabled = true warn("Asset compression disabled -- Java unavailable.") end diff --git a/lib/jammit/compressor.rb b/lib/jammit/compressor.rb index 5cda610f..08c8ed9c 100644 --- a/lib/jammit/compressor.rb +++ b/lib/jammit/compressor.rb @@ -71,7 +71,13 @@ def compress_js(paths) else js = concatenate(paths - jst_paths) + compile_jst(jst_paths) end - Jammit.compress_assets ? @js_compressor.compress(js) : js + if Jammit.compress_assets + @js_compressor.compress(js) + elsif @js_compressor.is_a?(Jammit::Uglifier) and Jammit.java_disabled # FIXME UGLY HACK + @js_compressor.compress(js) + else + js + end end # Concatenate and compress a list of CSS stylesheets. When compressing a @@ -80,7 +86,6 @@ def compress_js(paths) def compress_css(paths, variant=nil, asset_url=nil) @asset_contents = {} css = concatenate_and_tag_assets(paths, variant) - css = @css_compressor.compress(css) if Jammit.compress_assets case variant when nil then return css when :datauri then return with_data_uris(css)