aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/sprockets/helpers
diff options
context:
space:
mode:
authorSam Pohlenz <sam@sampohlenz.com>2011-09-01 14:59:16 +0930
committerSam Pohlenz <sam@sampohlenz.com>2011-09-01 17:41:42 +0930
commitd5165e5ab0829bd4cb0345f24ab619109cd1fbe2 (patch)
tree5d63701fdc8ee0939c2af765999c747ea586a112 /actionpack/lib/sprockets/helpers
parent3ce3b5b1f1f92d79ee015d246a9f62a725eca5ca (diff)
downloadrails-d5165e5ab0829bd4cb0345f24ab619109cd1fbe2.tar.gz
rails-d5165e5ab0829bd4cb0345f24ab619109cd1fbe2.tar.bz2
rails-d5165e5ab0829bd4cb0345f24ab619109cd1fbe2.zip
Move references to Rails.application.config out of Sprockets AssetPaths
Diffstat (limited to 'actionpack/lib/sprockets/helpers')
-rw-r--r--actionpack/lib/sprockets/helpers/rails_helper.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/actionpack/lib/sprockets/helpers/rails_helper.rb b/actionpack/lib/sprockets/helpers/rails_helper.rb
index 975dc9e80c..2dde2e9cc9 100644
--- a/actionpack/lib/sprockets/helpers/rails_helper.rb
+++ b/actionpack/lib/sprockets/helpers/rails_helper.rb
@@ -15,6 +15,8 @@ module Sprockets
paths.asset_environment = asset_environment
paths.asset_prefix = asset_prefix
paths.asset_digests = asset_digests
+ paths.compile_assets = compile_assets?
+ paths.digest_assets = digest_assets?
paths
end
end
@@ -60,8 +62,7 @@ module Sprockets
private
def debug_assets?
begin
- config = Rails.application.config.assets
- config.compile && (config.debug || params[:debug_assets])
+ compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets])
rescue NoMethodError
false
end
@@ -81,6 +82,14 @@ module Sprockets
Rails.application.config.assets.digests
end
+ def compile_assets?
+ Rails.application.config.assets.compile
+ end
+
+ def digest_assets?
+ Rails.application.config.assets.digest
+ end
+
# Override to specify an alternative asset environment for asset
# path generation. The environment should already have been mounted
# at the prefix returned by +asset_prefix+.
@@ -89,7 +98,7 @@ module Sprockets
end
class AssetPaths < ::ActionView::AssetPaths #:nodoc:
- attr_accessor :asset_environment, :asset_prefix, :asset_digests
+ attr_accessor :asset_environment, :asset_prefix, :asset_digests, :compile_assets, :digest_assets
class AssetNotPrecompiledError < StandardError; end
@@ -114,7 +123,7 @@ module Sprockets
return digest
end
- if Rails.application.config.assets.compile
+ if compile_assets
if asset = asset_environment[logical_path]
return asset.digest_path
end
@@ -128,7 +137,7 @@ module Sprockets
if source[0] == ?/
source
else
- source = digest_for(source) if Rails.application.config.assets.digest
+ source = digest_for(source) if digest_assets
source = File.join(dir, source)
source = "/#{source}" unless source =~ /^\//
source