44# to all of the configuration options.
55module Jammit
66
7- VERSION = "0.6.5"
7+ VERSION = "0.6.5"
88
9- ROOT = File . expand_path ( File . dirname ( __FILE__ ) + '/..' )
9+ ROOT = File . expand_path ( File . dirname ( __FILE__ ) + '/..' )
1010
11- ASSET_ROOT = File . expand_path ( ( defined? ( Rails ) && Rails . root . to_s . length > 0 ) ? Rails . root : ENV [ 'RAILS_ROOT' ] || "." ) unless defined? ( ASSET_ROOT )
11+ ASSET_ROOT = File . expand_path ( ( defined? ( Rails ) && Rails . root . to_s . length > 0 ) ? Rails . root : ENV [ 'RAILS_ROOT' ] || "." ) unless defined? ( ASSET_ROOT )
1212
13- DEFAULT_PUBLIC_ROOT = ( defined? ( Rails ) && Rails . public_path . to_s . length > 0 ) ? Rails . public_path : File . join ( ASSET_ROOT , 'public' ) unless defined? ( PUBLIC_ROOT )
13+ DEFAULT_PUBLIC_ROOT = ( defined? ( Rails ) && Rails . public_path . to_s . length > 0 ) ? Rails . public_path : File . join ( ASSET_ROOT , 'public' ) unless defined? ( PUBLIC_ROOT )
1414
15- DEFAULT_CONFIG_PATH = File . join ( ASSET_ROOT , 'config' , 'assets.yml' )
15+ DEFAULT_CONFIG_PATH = File . join ( ASSET_ROOT , 'config' , 'assets.yml' )
1616
17- DEFAULT_PACKAGE_PATH = "assets"
17+ DEFAULT_PACKAGE_PATH = "assets"
1818
19- DEFAULT_JST_SCRIPT = File . join ( ROOT , 'lib/jammit/jst.js' )
19+ DEFAULT_JST_SCRIPT = File . join ( ROOT , 'lib/jammit/jst.js' )
2020
21- DEFAULT_JST_COMPILER = "template"
21+ DEFAULT_JST_COMPILER = "template"
2222
23- DEFAULT_JST_NAMESPACE = "window.JST"
23+ DEFAULT_JST_NAMESPACE = "window.JST"
2424
25- COMPRESSORS = [ :yui , :closure , :uglifier ]
25+ JAVASCRIPT_COMPRESSORS = [ :jsmin , :yui , :closure , :uglifier ]
26+
27+ DEFAULT_JAVASCRIPT_COMPRESSOR = :jsmin
28+
29+ CSS_COMPRESSORS = [ :cssmin , :yui , :sass ]
30+
31+ DEFAULT_CSS_COMPRESSOR = :cssmin
2632
27- DEFAULT_COMPRESSOR = :yui
28-
2933 # Extension matchers for JavaScript and JST, which need to be disambiguated.
3034 JS_EXTENSION = /\. js\Z /
3135 DEFAULT_JST_EXTENSION = "jst"
@@ -50,17 +54,20 @@ class << self
5054 attr_reader :configuration , :template_function , :template_namespace ,
5155 :embed_assets , :package_assets , :compress_assets , :gzip_assets ,
5256 :package_path , :mhtml_enabled , :include_jst_script , :config_path ,
53- :javascript_compressor , :compressor_options , :css_compressor_options ,
54- :template_extension , :template_extension_matcher , :allow_debugging ,
57+ :javascript_compressor , :compressor_options , :css_compressor ,
58+ :css_compressor_options , :template_extension ,
59+ :template_extension_matcher , :allow_debugging ,
5560 :rewrite_relative_paths , :public_root
56- attr_accessor :compressors
61+ attr_accessor :javascript_compressors , :css_compressors
5762 end
5863
5964 # The minimal required configuration.
6065 @configuration = { }
6166 @public_root = DEFAULT_PUBLIC_ROOT
6267 @package_path = DEFAULT_PACKAGE_PATH
63- @compressors = COMPRESSORS
68+
69+ @javascript_compressors = JAVASCRIPT_COMPRESSORS
70+ @css_compressors = CSS_COMPRESSORS
6471
6572 # Load the complete asset configuration from the specified @config_path@.
6673 # If we're loading softly, don't let missing configuration error out.
@@ -86,6 +93,7 @@ def self.load_configuration(config_path, soft=false)
8693 @compressor_options = symbolize_keys ( conf [ :compressor_options ] || { } )
8794 @css_compressor_options = symbolize_keys ( conf [ :css_compressor_options ] || { } )
8895 set_javascript_compressor ( conf [ :javascript_compressor ] )
96+ set_css_compressor ( conf [ :css_compressor ] )
8997 set_package_assets ( conf [ :package_assets ] )
9098 set_template_function ( conf [ :template_function ] )
9199 set_template_namespace ( conf [ :template_namespace ] )
@@ -149,7 +157,13 @@ def self.set_public_root(public_root=nil)
149157 # Ensure that the JavaScript compressor is a valid choice.
150158 def self . set_javascript_compressor ( value )
151159 value = value && value . to_sym
152- @javascript_compressor = compressors . include? ( value ) ? value : DEFAULT_COMPRESSOR
160+ @javascript_compressor = javascript_compressors . include? ( value ) ? value : DEFAULT_JAVASCRIPT_COMPRESSOR
161+ end
162+
163+ # Ensure that the CSS compressor is a valid choice.
164+ def self . set_css_compressor ( value )
165+ value = value && value . to_sym
166+ @css_compressor = css_compressors . include? ( value ) ? value : DEFAULT_CSS_COMPRESSOR
153167 end
154168
155169 # Turn asset packaging on or off, depending on configuration and environment.
0 commit comments