diff options
author | Joshua Peek <josh@joshpeek.com> | 2011-03-21 17:58:28 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2011-03-21 17:58:28 -0500 |
commit | 3e7985c9c1a6899ac06857bd8e6f29b48ad87cea (patch) | |
tree | 1c8201ec82d6956e85b1af467fc93cb7da03a808 /railties/lib | |
parent | 88636f7195fc936421392740f980d17ebe77d701 (diff) | |
download | rails-3e7985c9c1a6899ac06857bd8e6f29b48ad87cea.tar.gz rails-3e7985c9c1a6899ac06857bd8e6f29b48ad87cea.tar.bz2 rails-3e7985c9c1a6899ac06857bd8e6f29b48ad87cea.zip |
Add sprockets environment to Application
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 94819820bc..3415cc5a5d 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -137,6 +137,40 @@ module Rails @config ||= Application::Configuration.new(find_root_with_flag("config.ru", Dir.pwd)) end + def self.default_sprockets_paths + [ + "app/assets", + "app/javascripts", + "app/stylesheets", + "vendor/plugins/*/app/assets", + "vendor/plugins/*/app/javascripts", + "vendor/plugins/*/app/stylesheets", + "vendor/plugins/*/assets", + "vendor/plugins/*/javascripts", + "vendor/plugins/*/stylesheets" + ] + end + + def assets + @assets ||= build_asset_environment + end + + def build_asset_environment + require 'sprockets' + + env = Sprockets::Environment.new(root.to_s) + env.logger = Rails.logger + env.ensure_fresh_assets = !config.action_controller.perform_caching + + self.class.default_sprockets_paths.each do |pattern| + Dir[root.join(pattern)].each do |dir| + env.paths << dir + end + end + + env + end + protected def default_asset_path |