jammit 0.2.3 → 0.2.4
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 +11 -4
- data/lib/jammit/compressor.rb +1 -1
- data/lib/jammit/controller.rb +1 -1
- data/lib/jammit/packager.rb +1 -1
- metadata +1 -1
data/jammit.gemspec
CHANGED
data/lib/jammit.rb
CHANGED
@@ -4,11 +4,13 @@ $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.4"
|
8
8
|
|
9
9
|
ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
|
10
10
|
|
11
|
-
|
11
|
+
ASSET_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : "."
|
12
|
+
|
13
|
+
DEFAULT_CONFIG_PATH = "#{ASSET_ROOT}/config/assets.yml"
|
12
14
|
|
13
15
|
DEFAULT_PACKAGE_PATH = "assets"
|
14
16
|
|
@@ -24,6 +26,10 @@ module Jammit
|
|
24
26
|
# requested by a browser -- rendering a 404.
|
25
27
|
class PackageNotFound < NameError; end
|
26
28
|
|
29
|
+
# Jammit raises a ConfigurationNotFound exception when you try to load the
|
30
|
+
# configuration of an assets.yml file that doesn't exist.
|
31
|
+
class ConfigurationNotFound < NameError; end
|
32
|
+
|
27
33
|
class << self
|
28
34
|
attr_reader :configuration, :template_function, :embed_images, :package_path,
|
29
35
|
:package_assets, :mhtml_enabled, :include_jst_script,
|
@@ -36,9 +42,10 @@ module Jammit
|
|
36
42
|
|
37
43
|
# Load the complete asset configuration from the specified @config_path@.
|
38
44
|
def self.load_configuration(config_path)
|
39
|
-
|
45
|
+
conf = config_path && File.exists?(config_path) && YAML.load_file(config_path)
|
46
|
+
raise ConfigurationNotFound, "could not find the \"#{config_path}\" configuration file" unless conf
|
40
47
|
@config_path = config_path
|
41
|
-
@configuration = conf =
|
48
|
+
@configuration = conf = conf.symbolize_keys
|
42
49
|
@package_path = conf[:package_path] || DEFAULT_PACKAGE_PATH
|
43
50
|
@embed_images = conf[:embed_images]
|
44
51
|
@mhtml_enabled = @embed_images && @embed_images != "datauri"
|
data/lib/jammit/compressor.rb
CHANGED
@@ -124,7 +124,7 @@ module Jammit
|
|
124
124
|
# not be relative, given the path of the stylesheet that contains it.
|
125
125
|
def public_path(image_path, css_path)
|
126
126
|
image_path, css_path = Pathname.new(image_path), Pathname.new(css_path)
|
127
|
-
(image_path.absolute? ? Pathname.new("public#{image_path}") : css_path.dirname + image_path).cleanpath
|
127
|
+
(image_path.absolute? ? Pathname.new("#{ASSET_ROOT}/public#{image_path}") : css_path.dirname + image_path).cleanpath
|
128
128
|
end
|
129
129
|
|
130
130
|
# An image is valid if it exists, and is less than 32K.
|
data/lib/jammit/controller.rb
CHANGED
data/lib/jammit/packager.rb
CHANGED
@@ -30,7 +30,7 @@ module Jammit
|
|
30
30
|
# versions. In order to prebuild the MHTML stylesheets, we need to know the
|
31
31
|
# base_url, because IE only supports MHTML with absolute references.
|
32
32
|
def precache_all(output_dir=nil, base_url=nil)
|
33
|
-
output_dir ||= "public/#{Jammit.package_path}"
|
33
|
+
output_dir ||= "#{ASSET_ROOT}/public/#{Jammit.package_path}"
|
34
34
|
@config[:js].keys.each {|p| cache(p, 'js', pack_javascripts(p), output_dir) }
|
35
35
|
@config[:jst].keys.each {|p| cache(p, 'jst', pack_templates(p), output_dir) }
|
36
36
|
@config[:css].keys.each do |p|
|