diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-08-08 21:21:04 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-08-08 21:21:04 +0000 |
commit | 74165eb6acaca98d4da13409c4e5b5ecc9d260f7 (patch) | |
tree | 024158d20563f34cca52a00b42aaa6c922777559 /railties/lib | |
parent | 94a1309194fa5962e33d395ede14e94b237c54f5 (diff) | |
download | rails-74165eb6acaca98d4da13409c4e5b5ecc9d260f7.tar.gz rails-74165eb6acaca98d4da13409c4e5b5ecc9d260f7.tar.bz2 rails-74165eb6acaca98d4da13409c4e5b5ecc9d260f7.zip |
New dependencies implementation
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4728 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/initializer.rb | 41 | ||||
-rw-r--r-- | railties/lib/webrick_server.rb | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 8abc3231db..ef83c2c259 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -80,6 +80,7 @@ module Rails set_connection_adapters require_frameworks + set_autoload_paths load_environment initialize_database @@ -125,6 +126,13 @@ module Rails $LOAD_PATH.uniq! end + # Set the paths from which Rails will automatically load source files. + def set_autoload_paths + Dependencies.autoload_paths = configuration.autoload_paths.uniq + # Freeze the array so future modifications will fail rather than do nothing mysteriously + configuration.autoload_paths.freeze + end + # Sets the +RAILS_CONNECTION_ADAPTERS+ constant based on the value of # Configuration#connection_adapters. This constant is used to determine # which database adapters should be loaded (by default, all adapters are @@ -412,6 +420,11 @@ module Rails # all +app+, +lib+, +vendor+ and mock paths are included in this list. attr_accessor :load_paths + # An array of paths from which Rails will automatically load classes and + # modules from. By default, all +app+, +lib+, +vendor+ and mock paths are + # included in this list. + attr_accessor :autoload_paths + # The log level to use for the default Rails logger. In production mode, # this defaults to <tt>:info</tt>. In development mode, it defaults to # <tt>:debug</tt>. @@ -443,6 +456,7 @@ module Rails def initialize self.frameworks = default_frameworks self.load_paths = default_load_paths + self.autoload_paths = default_autoload_paths self.log_path = default_log_path self.log_level = default_log_level self.view_path = default_view_path @@ -546,6 +560,33 @@ module Rails actionwebservice/lib ).map { |dir| "#{framework_root_path}/#{dir}" }.select { |dir| File.directory?(dir) } end + + def default_autoload_paths + paths = [] + + # Add the app's controller directory + paths.concat(Dir["#{root_path}/app/controllers/"]) + + # Then model subdirectories. + # TODO: Don't include .rb models as load paths + paths.concat(Dir["#{root_path}/app/models/[_a-z]*"]) + paths.concat(Dir["#{root_path}/components/[_a-z]*"]) + + # Followed by the standard includes. + paths.concat %w( + app + app/models + app/controllers + app/helpers + app/services + app/apis + components + config + lib + ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } + + paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"] + end def default_log_path File.join(root_path, 'log', "#{environment}.log") diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb index 8f4ddb11a3..984638c8cc 100644 --- a/railties/lib/webrick_server.rb +++ b/railties/lib/webrick_server.rb @@ -3,6 +3,7 @@ require 'webrick' require 'cgi' require 'stringio' +require 'dispatcher' include WEBrick |