From 57edb69144b5987eb9d495c9ab60e7183f92c412 Mon Sep 17 00:00:00 2001 From: Ivan Evtukhovich Date: Mon, 4 Jul 2011 20:03:36 +0400 Subject: [PATCH 1/5] Now works without Java and withoud YUI --- jammit.gemspec | 2 -- lib/jammit.rb | 4 +++- lib/jammit/compressor.rb | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/jammit.gemspec b/jammit.gemspec index 537e5416..4b17e6d8 100644 --- a/jammit.gemspec +++ b/jammit.gemspec @@ -26,7 +26,5 @@ Gem::Specification.new do |s| '--main' << 'README' << '--all' - 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..594fbf8f 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 From 8b21f3051b315ba125a179162110c927473560c3 Mon Sep 17 00:00:00 2001 From: Ivan Evtukhovich Date: Tue, 5 Jul 2011 10:27:03 +0400 Subject: [PATCH 2/5] Do not breaks when there is no yui --- lib/jammit/dependencies.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/jammit/dependencies.rb b/lib/jammit/dependencies.rb index 86bfa79c..4110e6b6 100644 --- a/lib/jammit/dependencies.rb +++ b/lib/jammit/dependencies.rb @@ -8,7 +8,11 @@ require 'fileutils' # Include YUI as the default -require 'yui/compressor' +begin + require 'yui/compressor' +rescue LoadError + Jammit.compressors.delete :yui +end # Try Closure. begin From 9a7376ba0ccfc109a65af2f687d9abdbbd52285f Mon Sep 17 00:00:00 2001 From: Ivan Evtukhovich Date: Tue, 5 Jul 2011 11:04:08 +0400 Subject: [PATCH 3/5] Without yui jammit is not working --- jammit.gemspec | 1 + lib/jammit/dependencies.rb | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/jammit.gemspec b/jammit.gemspec index 4b17e6d8..8abee451 100644 --- a/jammit.gemspec +++ b/jammit.gemspec @@ -25,6 +25,7 @@ Gem::Specification.new do |s| '--exclude' << 'test' << '--main' << 'README' << '--all' + s.add_dependency 'yui-compressor', ['>= 0.9.3'] s.files = Dir['lib/**/*', 'bin/*', 'rails/*', 'jammit.gemspec', 'LICENSE', 'README'] end diff --git a/lib/jammit/dependencies.rb b/lib/jammit/dependencies.rb index 4110e6b6..86bfa79c 100644 --- a/lib/jammit/dependencies.rb +++ b/lib/jammit/dependencies.rb @@ -8,11 +8,7 @@ require 'fileutils' # Include YUI as the default -begin - require 'yui/compressor' -rescue LoadError - Jammit.compressors.delete :yui -end +require 'yui/compressor' # Try Closure. begin From 54d7247bf4519e1a267a3b28716634ee39eb5044 Mon Sep 17 00:00:00 2001 From: Ivan Evtukhovich Date: Sat, 12 May 2012 15:23:20 +0400 Subject: [PATCH 4/5] We do not use java in our jammit --- lib/jammit/compressor.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jammit/compressor.rb b/lib/jammit/compressor.rb index 594fbf8f..94246c7c 100644 --- a/lib/jammit/compressor.rb +++ b/lib/jammit/compressor.rb @@ -86,7 +86,7 @@ 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 + css = @css_compressor.compress(css) if Jammit.compress_assets && !Jammit.java_disabled case variant when nil then return css when :datauri then return with_data_uris(css) From 1c014568b65785d5fa4f53bbd15ba8450f8ab44a Mon Sep 17 00:00:00 2001 From: Ivan Evtukhovich Date: Sat, 12 May 2012 15:32:49 +0400 Subject: [PATCH 5/5] Disable java for css --- lib/jammit/compressor.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jammit/compressor.rb b/lib/jammit/compressor.rb index 94246c7c..08c8ed9c 100644 --- a/lib/jammit/compressor.rb +++ b/lib/jammit/compressor.rb @@ -86,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 && !Jammit.java_disabled case variant when nil then return css when :datauri then return with_data_uris(css)