jammit 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jammit'
3
- s.version = '0.2.2' # Keep version in sync with jammit.rb
3
+ s.version = '0.2.3' # Keep version in sync with jammit.rb
4
4
  s.date = '2009-11-18'
5
5
 
6
6
  s.homepage = "http://documentcloud.github.com/jammit/"
@@ -4,19 +4,21 @@ $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.2.2"
7
+ VERSION = "0.2.3"
8
8
 
9
9
  ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
10
10
 
11
- DEFAULT_CONFIG_PATH = "config/assets.yml"
11
+ DEFAULT_CONFIG_PATH = "config/assets.yml"
12
12
 
13
- DEFAULT_PACKAGE_PATH = "assets"
13
+ DEFAULT_PACKAGE_PATH = "assets"
14
14
 
15
- DEFAULT_JST_SCRIPT = "#{ROOT}/lib/jammit/jst.js"
15
+ DEFAULT_JST_SCRIPT = "#{ROOT}/lib/jammit/jst.js"
16
16
 
17
- DEFAULT_JST_COMPILER = "template"
17
+ DEFAULT_JST_COMPILER = "template"
18
18
 
19
- DEFAULT_COMPRESSOR = :yui
19
+ AVAILABLE_COMPRESSORS = [:yui, :closure]
20
+
21
+ DEFAULT_COMPRESSOR = :yui
20
22
 
21
23
  # Jammit raises a @PackageNotFound@ exception when a non-existent package is
22
24
  # requested by a browser -- rendering a 404.
@@ -40,8 +42,8 @@ module Jammit
40
42
  @package_path = conf[:package_path] || DEFAULT_PACKAGE_PATH
41
43
  @embed_images = conf[:embed_images]
42
44
  @mhtml_enabled = @embed_images && @embed_images != "datauri"
43
- @javascript_compressor = (conf[:javascript_compressor] || DEFAULT_COMPRESSOR).to_sym
44
45
  @compressor_options = conf[:compressor_options] || {}
46
+ set_javascript_compressor(conf[:javascript_compressor])
45
47
  set_package_assets(conf[:package_assets])
46
48
  set_template_function(conf[:template_function])
47
49
  self
@@ -75,6 +77,11 @@ module Jammit
75
77
 
76
78
  private
77
79
 
80
+ def self.set_javascript_compressor(value)
81
+ value = value && value.to_sym
82
+ @javascript_compressor = AVAILABLE_COMPRESSORS.include?(value) ? value : DEFAULT_COMPRESSOR
83
+ end
84
+
78
85
  def self.set_package_assets(value)
79
86
  package_env = !defined?(RAILS_ENV) || RAILS_ENV != 'development'
80
87
  @package_assets = case value
@@ -41,7 +41,7 @@ module Jammit
41
41
  def initialize
42
42
  @css_compressor = YUI::CssCompressor.new
43
43
  flavor = Jammit.javascript_compressor
44
- js_options = (DEFAULT_OPTIONS[flavor] || {}).merge(Jammit.compressor_options)
44
+ js_options = DEFAULT_OPTIONS[flavor].merge(Jammit.compressor_options)
45
45
  @js_compressor = flavor == :closure ?
46
46
  Closure::Compiler.new(js_options) :
47
47
  YUI::JavaScriptCompressor.new(js_options)
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas