jammit 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -11,7 +11,7 @@
11
11
  template support, and optional Data-URI / MHTML image embedding.
12
12
 
13
13
  Installation:
14
- gem install jammit --source http://gemcutter.org
14
+ gem install jammit
15
15
 
16
16
  For documentation, usage, and examples, see:
17
17
  http://documentcloud.github.com/jammit/
data/jammit.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jammit'
3
- s.version = '0.3.2' # Keep version in sync with jammit.rb
4
- s.date = '2009-12-03'
3
+ s.version = '0.3.3' # Keep version in sync with jammit.rb
4
+ s.date = '2009-1-5'
5
5
 
6
6
  s.homepage = "http://documentcloud.github.com/jammit/"
7
7
  s.summary = "Industrial Strength Asset Packaging for Rails"
data/lib/jammit.rb CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path(File.dirname(__FILE__))
4
4
  # to all of the configuration options.
5
5
  module Jammit
6
6
 
7
- VERSION = "0.3.2"
7
+ VERSION = "0.3.3"
8
8
 
9
9
  ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
10
10
 
@@ -38,8 +38,8 @@ module Jammit
38
38
 
39
39
  class << self
40
40
  attr_reader :configuration, :template_function, :embed_images, :package_path,
41
- :package_assets, :mhtml_enabled, :include_jst_script,
42
- :javascript_compressor, :compressor_options
41
+ :package_assets, :compress_assets, :mhtml_enabled, :include_jst_script,
42
+ :javascript_compressor, :compressor_options, :css_compressor_options
43
43
  end
44
44
 
45
45
  # The minimal required configuration.
@@ -54,8 +54,10 @@ module Jammit
54
54
  @configuration = conf = conf.symbolize_keys
55
55
  @package_path = conf[:package_path] || DEFAULT_PACKAGE_PATH
56
56
  @embed_images = conf[:embed_images]
57
+ @compress_assets = !(conf[:compress_assets] == false)
57
58
  @mhtml_enabled = @embed_images && @embed_images != "datauri"
58
59
  @compressor_options = (conf[:compressor_options] || {}).symbolize_keys
60
+ @css_compressor_options = (conf[:css_compressor_options] || {}).symbolize_keys
59
61
  set_javascript_compressor(conf[:javascript_compressor])
60
62
  set_package_assets(conf[:package_assets])
61
63
  set_template_function(conf[:template_function])
@@ -114,6 +116,7 @@ module Jammit
114
116
  # The YUI Compressor requires Java > 1.4, and Closure requires Java > 1.6.
115
117
  def self.check_java_version
116
118
  java = @compressor_options[:java] || 'java'
119
+ @css_compressor_options[:java] ||= java if @compressor_options[:java]
117
120
  version = (`#{java} -version 2>&1`)[/\d+\.\d+/]
118
121
  disable_compression if !version ||
119
122
  (@javascript_compressor == :closure && version < '1.6') ||
@@ -123,7 +126,7 @@ module Jammit
123
126
  # If we don't have a working Java VM, then disable asset compression and
124
127
  # complain loudly.
125
128
  def self.disable_compression
126
- @compressor_options[:disabled] = true
129
+ @compress_assets = false
127
130
  complaint = "Warning: Jammit asset compression disabled -- Java unavailable."
128
131
  defined?(Rails) ? Rails.logger.warn(complaint) : STDERR.puts(complaint)
129
132
  end
@@ -45,7 +45,7 @@ module Jammit
45
45
  # the "yui-compressor" gem, or the internal Closure Compiler from the
46
46
  # "closure-compiler" gem.
47
47
  def initialize
48
- @css_compressor = YUI::CssCompressor.new
48
+ @css_compressor = YUI::CssCompressor.new(Jammit.css_compressor_options)
49
49
  flavor = Jammit.javascript_compressor
50
50
  @options = DEFAULT_OPTIONS[flavor].merge(Jammit.compressor_options)
51
51
  @js_compressor = COMPRESSORS[flavor].new(@options)
@@ -55,7 +55,7 @@ module Jammit
55
55
  # YUI Compressor (with munging enabled).
56
56
  def compress_js(paths)
57
57
  js = concatenate(paths)
58
- @options[:disabled] ? js : @js_compressor.compress(js)
58
+ Jammit.compress_assets ? @js_compressor.compress(js) : js
59
59
  end
60
60
 
61
61
  # Concatenate and compress a list of CSS stylesheets. When compressing a
@@ -63,7 +63,7 @@ module Jammit
63
63
  # referenced images.
64
64
  def compress_css(paths, variant=nil, asset_url=nil)
65
65
  css = concatenate_and_tag_images(paths, variant)
66
- css = @css_compressor.compress(css) unless @options[:disabled]
66
+ css = @css_compressor.compress(css) if Jammit.compress_assets
67
67
  case variant
68
68
  when nil then return css
69
69
  when :datauri then return with_data_uris(css)
@@ -7,7 +7,7 @@ module Jammit
7
7
  class Packager
8
8
 
9
9
  # In Rails, the difference between a path and an asset URL is "public".
10
- PATH_TO_URL = /\A#{ASSET_ROOT}(\/public)?/
10
+ PATH_TO_URL = /\A#{Regexp.escape(ASSET_ROOT)}(\/public)?/
11
11
 
12
12
  # Set force to false to allow packages to only be rebuilt when their source
13
13
  # files have changed since the last time their package was built.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jammit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-03 00:00:00 -05:00
12
+ date: 2009-01-05 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency