jammit 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/jammit.gemspec +2 -2
- data/lib/jammit.rb +23 -14
- metadata +2 -2
data/jammit.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'jammit'
|
3
|
-
s.version = '0.2.
|
4
|
-
s.date = '2009-11-
|
3
|
+
s.version = '0.2.6' # Keep version in sync with jammit.rb
|
4
|
+
s.date = '2009-11-19'
|
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.2.
|
7
|
+
VERSION = "0.2.6"
|
8
8
|
|
9
9
|
ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
|
10
10
|
|
@@ -30,6 +30,10 @@ module Jammit
|
|
30
30
|
# configuration of an assets.yml file that doesn't exist.
|
31
31
|
class ConfigurationNotFound < NameError; end
|
32
32
|
|
33
|
+
# Jammit raises a JavaNotFound exception if Java is not installed, or it's
|
34
|
+
# not a recent enough version to run the JavaScript compressor.
|
35
|
+
class JavaNotFound < StandardError; end
|
36
|
+
|
33
37
|
class << self
|
34
38
|
attr_reader :configuration, :template_function, :embed_images, :package_path,
|
35
39
|
:package_assets, :mhtml_enabled, :include_jst_script,
|
@@ -49,10 +53,11 @@ module Jammit
|
|
49
53
|
@package_path = conf[:package_path] || DEFAULT_PACKAGE_PATH
|
50
54
|
@embed_images = conf[:embed_images]
|
51
55
|
@mhtml_enabled = @embed_images && @embed_images != "datauri"
|
52
|
-
@compressor_options = conf[:compressor_options] || {}
|
56
|
+
@compressor_options = (conf[:compressor_options] || {}).symbolize_keys
|
53
57
|
set_javascript_compressor(conf[:javascript_compressor])
|
54
58
|
set_package_assets(conf[:package_assets])
|
55
59
|
set_template_function(conf[:template_function])
|
60
|
+
check_java_version
|
56
61
|
self
|
57
62
|
end
|
58
63
|
|
@@ -84,31 +89,35 @@ module Jammit
|
|
84
89
|
|
85
90
|
private
|
86
91
|
|
92
|
+
# Ensure that the JavaScript compressor is a valid choice.
|
87
93
|
def self.set_javascript_compressor(value)
|
88
94
|
value = value && value.to_sym
|
89
95
|
@javascript_compressor = AVAILABLE_COMPRESSORS.include?(value) ? value : DEFAULT_COMPRESSOR
|
90
96
|
end
|
91
97
|
|
98
|
+
# Turn asset packaging on or off, depending on configuration and environment.
|
92
99
|
def self.set_package_assets(value)
|
93
100
|
package_env = !defined?(RAILS_ENV) || RAILS_ENV != 'development'
|
94
|
-
@package_assets =
|
95
|
-
|
96
|
-
when false then false
|
97
|
-
when true then package_env
|
98
|
-
when nil then package_env
|
99
|
-
end
|
101
|
+
@package_assets = value == true || value.nil? ? package_env :
|
102
|
+
value == 'always' ? true : false
|
100
103
|
end
|
101
104
|
|
105
|
+
# Assign the JST template function, unless explicitly turned off.
|
102
106
|
def self.set_template_function(value)
|
103
|
-
@template_function =
|
104
|
-
|
105
|
-
when true then DEFAULT_JST_COMPILER
|
106
|
-
when nil then DEFAULT_JST_COMPILER
|
107
|
-
else value
|
108
|
-
end
|
107
|
+
@template_function = value == true || value.nil? ? DEFAULT_JST_COMPILER :
|
108
|
+
value == false ? '' : value
|
109
109
|
@include_jst_script = @template_function == DEFAULT_JST_COMPILER
|
110
110
|
end
|
111
111
|
|
112
|
+
# The YUI Compressor requires Java > 1.4, and Closure requires Java > 1.6.
|
113
|
+
def self.check_java_version
|
114
|
+
java = @compressor_options[:java] || 'java'
|
115
|
+
version = (`#{java} -version 2>&1`).match(/\d+\.\d+/)[0] rescue false
|
116
|
+
raise JavaNotFound, "the \"#{java}\" command could not be found" unless version
|
117
|
+
raise JavaNotFound, "the closure compiler requires Java 6 (1.6) or greater" if @javascript_compressor == :closure && version < '1.6'
|
118
|
+
raise JavaNotFound, "the YUI compressor requires Java 1.4 or greater" if @javascript_compressor == :yui && version < '1.4'
|
119
|
+
end
|
120
|
+
|
112
121
|
end
|
113
122
|
|
114
123
|
# Standard Library Dependencies:
|
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.
|
4
|
+
version: 0.2.6
|
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-11-
|
12
|
+
date: 2009-11-19 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|