Permalink
Browse files

Add experimental plugin support #2335

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2465 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d364164 commit 7a854b53792ae7eecae20078545ea1d06ed34552 @jamis jamis committed Oct 5, 2005
Showing with 28 additions and 1 deletion.
  1. +2 −0 railties/CHANGELOG
  2. +26 −1 railties/lib/initializer.rb
View
2 railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add experimental plugin support #2335
+
* Removed all the scripts in script/* and replaced it with one generic portal: script/run
* Made Rakefile aware of new .js files in script.aculo.us [Thomas Fuchs]
View
27 railties/lib/initializer.rb
@@ -33,6 +33,7 @@ def process
set_connection_adapters
require_frameworks
+ load_plugins
load_environment
initialize_database
@@ -65,6 +66,26 @@ def require_frameworks
configuration.frameworks.each { |framework| require(framework.to_s) }
end
+ def load_plugins
+ config = configuration
+
+ Dir.glob("#{configuration.plugins_path}/*") do |directory|
+ next if File.basename(directory)[0] == ?. || !File.directory?(directory)
+
+ if File.exist?("#{directory}/init.rb")
+ silence_warnings do
+ eval(IO.read("#{directory}/init.rb"), binding)
+ end
+ end
+
+ if File.directory?("#{directory}/lib")
+ $LOAD_PATH.unshift "#{directory}/lib"
+ end
+ end
+
+ $LOAD_PATH.uniq!
+ end
+
def load_environment
silence_warnings do
config = configuration
@@ -177,6 +198,10 @@ def database_configuration
def environment_path
"#{RAILS_ROOT}/config/environments/#{environment}.rb"
end
+
+ def plugins_path
+ "#{RAILS_ROOT}/vendor/plugins"
+ end
def environment
::RAILS_ENV
@@ -286,4 +311,4 @@ def find_pair(key)
self.each { |i| return i if i.first == key }
return false
end
-end
+end

0 comments on commit 7a854b5

Please sign in to comment.