aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2011-03-30 21:56:15 -0500
committerJoshua Peek <josh@joshpeek.com>2011-03-30 21:56:15 -0500
commit28fee29e383258c38649e20dc9508188010020c8 (patch)
treef2cbc6faa5a7993839271f0557a0f647397d3f21
parent56a5da89dbcdd6d73f26f5c1be6221b684574b2b (diff)
downloadrails-28fee29e383258c38649e20dc9508188010020c8.tar.gz
rails-28fee29e383258c38649e20dc9508188010020c8.tar.bz2
rails-28fee29e383258c38649e20dc9508188010020c8.zip
Unify sprockets config options
-rw-r--r--actionpack/lib/action_controller/railtie.rb2
-rw-r--r--railties/lib/rails/application.rb24
-rw-r--r--railties/lib/rails/application/configuration.rb10
-rw-r--r--railties/lib/rails/application/finisher.rb7
4 files changed, 25 insertions, 18 deletions
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb
index 175b7744d7..0dd13fa9bf 100644
--- a/actionpack/lib/action_controller/railtie.rb
+++ b/actionpack/lib/action_controller/railtie.rb
@@ -21,7 +21,7 @@ module ActionController
paths = app.config.paths
options = app.config.action_controller
- options.use_sprockets ||= app.config.asset_pipeline
+ options.use_sprockets ||= app.config.assets.enabled
options.assets_dir ||= paths["public"].first
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 5b8841fd97..d9c183d93e 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -142,23 +142,25 @@ module Rails
end
def build_asset_environment
- return unless config.asset_pipeline
+ return unless config.assets.enabled
require 'sprockets'
env = Sprockets::Environment.new(root.to_s)
- env.static_root = root.join("public/assets")
+ env.static_root = root.join("public/#{config.assets.prefix}")
env
end
initializer :add_sprockets_paths do |app|
- if config.asset_pipeline
- [
- "app/javascripts",
- "app/stylesheets",
- "vendor/plugins/*/app/javascripts",
- "vendor/plugins/*/app/stylesheets",
- "vendor/plugins/*/javascripts",
- "vendor/plugins/*/stylesheets"
- ].each do |pattern|
+ if config.assets.enabled
+ paths = [
+ "app/javascripts",
+ "app/stylesheets",
+ "vendor/plugins/*/app/javascripts",
+ "vendor/plugins/*/app/stylesheets",
+ "vendor/plugins/*/javascripts",
+ "vendor/plugins/*/stylesheets"
+ ] + config.assets.paths
+
+ paths.each do |pattern|
Dir[app.root.join(pattern)].each do |dir|
app.assets.paths << dir
end
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 4ec5336f6c..4a042e0033 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -10,7 +10,7 @@ module Rails
:preload_frameworks, :reload_plugins,
:secret_token, :serve_static_assets, :session_options,
:time_zone, :whiny_nils, :force_ssl,
- :asset_pipeline, :precompile_assets
+ :assets
attr_writer :log_level
@@ -30,8 +30,12 @@ module Rails
@log_level = nil
@middleware = app_middleware
@generators = app_generators
- @asset_pipeline = false
- @precompile_assets = []
+
+ @assets = ActiveSupport::OrderedOptions.new
+ @assets.enabled = false
+ @assets.paths = []
+ @assets.precompile = []
+ @assets.prefix = "/assets"
end
def compiled_asset_path
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 3cfd8f5707..be063e5f25 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -34,15 +34,16 @@ module Rails
end
initializer :add_sprockets_route do |app|
- if config.asset_pipeline
+ assets = config.assets
+ if assets.enabled
app.routes.append do
- mount app.assets => "/assets"
+ mount app.assets => assets.prefix
end
end
end
initializer :set_sprockets_logger do |app|
- if config.asset_pipeline
+ if config.assets.enabled
app.assets.logger = Rails.logger
end
end