jammit 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/jammit.gemspec +1 -1
- data/lib/jammit.rb +14 -7
- data/lib/jammit/compressor.rb +1 -1
- metadata +1 -1
data/jammit.gemspec
CHANGED
data/lib/jammit.rb
CHANGED
@@ -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.
|
7
|
+
VERSION = "0.2.3"
|
8
8
|
|
9
9
|
ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
|
10
10
|
|
11
|
-
DEFAULT_CONFIG_PATH
|
11
|
+
DEFAULT_CONFIG_PATH = "config/assets.yml"
|
12
12
|
|
13
|
-
DEFAULT_PACKAGE_PATH
|
13
|
+
DEFAULT_PACKAGE_PATH = "assets"
|
14
14
|
|
15
|
-
DEFAULT_JST_SCRIPT
|
15
|
+
DEFAULT_JST_SCRIPT = "#{ROOT}/lib/jammit/jst.js"
|
16
16
|
|
17
|
-
DEFAULT_JST_COMPILER
|
17
|
+
DEFAULT_JST_COMPILER = "template"
|
18
18
|
|
19
|
-
|
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
|
data/lib/jammit/compressor.rb
CHANGED
@@ -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 =
|
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)
|